That's how geothermal heat pumps work. It is possible to have geothermal heat pumps that only extract heat, but then you need much deeper wells.
Last place I lived replaced our oil furnaces with geothermal heat pumps back when oil furnaces were banned back in 2020, but the in-apartment bit was old radiators, which aren't suitable for absorbing heat, so we had to get some energy wells that were a few hundred meters deep.
… and still swelter in summer :|