The compressor (pictured below) does the same thing your refrigerator compressor does. It compresses a refrigerant gas to heat it. Then, it sends that heated refrigerant gas to the exchanger that it targets, the inside exchanger in the winter, the ground loop exchanger in the summer. The targeted heat exchanger is then warmed by that hot gas.
This cools the gas because when something hot comes into contact with something colder, heat always flows from the hotter thing to the colder thing. Now that gas is robbed of it's heat (because it is in your home now making you comfortable!), it flows to the other side of the heat exchanger circuit. That gas is now a lot colder than normal and absorbs any available heat energy, like the inside part of your refrigerator absorbs the heat energy from the milk, making it colder (or the earth in your ground loop absorbs all that sweltering heat that you are trying to get rid of on a blistering summer day). A simple refrigeration chart is seen below right.
Click on a component to learn more about it