Heat pumps move heat energy from one place to another. That’s it, that’s all they do (hence the name “pump”).
The heat pump in your refrigerator moves the heat from the inside of the insulated box and releases it into the room. The heat pump in window air conditioner takes the heat out of a room and vents it to the outside. A ground source heat pump can remove heat from the ground and release it into a structure or it can remove heat from a structure and release it into the ground.
The efficiency of this heat transfer greatly depends on the load and the source temperatures.
Think of a hot summer day. A window air conditioner must remove heat from the room and reject it into the already hot summer air. While the temperature of the refrigerant far exceeds the ambient outdoor temperature it has reduced capacity to release heat as the temperature increases. If the air conditioner could release the heat it has removed from the room into the cool earth below the home it could get rid of the heat much faster than trying to reject it into the hot summer air.
Now think of a cold winter day. The colder it gets outside a home, the less efficient it is to remove heat from the cold ambient air and deliver it to the warm home.
The earth provides a thermal mass with a consistent moderate temperature.
The sun provided the thermal energy. The earth absorbed it. Heat pumps can move it.