I am assuming if a gas warms when it is compressed, it also gains energy? (energy~temp).
I'll toss my hat into this ring too. Meaning no disrespect to the above replies, I think there is a strong tendency to overcomplicate things. While they all explain the phenomenon, the goal on the MCAT is to keep things simple and answer the question quickly.
The scenario you describe is based on conversion of energy from one form into another form. In this case from chemical potential into heat energy. As a gas is compressed (open, closed, isolated or whatever), the particles get closer together. While no bond is formed per say, it is similar to the bond-forming process because intermolecular attraction will increase. This is assuming the gas is made up of molecules that can condense if the pressure is high enough (a highly probable assumption). Bond formation is an exothermic process, so as the particles get closer together, they release heat energy. In essense, chemical potential energy has been converted into heat energy. The molecules in the system absorb this thermal energy and thus experience an increase in their temperature. If the system is open, then this heat energy readily escapes. If the system is isolated, then the system experiences an increase in temperature due to this extra heat energy.
A phase change of a gas into a liquid driven by compression is just an extreme case of this example.
If you are having trouble with this example, you can always consider the reverse process. If you expand a gas, then it should become colder. You have no doubt felt this first hand (pun intended) when holding an aerosol can and releasing the contents. It gets cold to the touch, because as the gas particles remaining in the can move away from one another, it is in essense a bond-breaking scenario, and therefore is endothermic. The molecules in the system absorb the surrounding heat energy so they can expand, making it feel cold to the touch (the system is stealing your heat). Hopefully this helps with the visualization process.
If it gains energy then why do gases at high pressure and constant temperature lose energy and become liquid? Wouldn't they gain energy and stay in the gas phase?
The key constraint you added to your question is
constant temperature. As the gas is compressed, heat will be released into the environment. That would raise the temperature. The only way to maintain the temperature would be to remove that heat (cool the system by allowing heat to escape to the environment). Because you have allowed for the loss of heat to the environment, you have in fact taken the system to a lower energy state, which explains the phase change.