AT a small depth (from 12 to 40 feet) below the surface of the earth the temperature is constant throughout the year.
The ground is cooler in summer and warmer in winter than the air above it.
The underground temperature is 33 degrees. In summer, the air temperature is 45 degrees, and in winter it’s 5, but underground it’s still 33. It’s not that hard to get that constant temperature out of the ground so you can heat in winter and cool in summer.