The energy balance
A heat pump obeys conservation of energy: heat delivered equals heat drawn from the ground plus the electricity the compressor uses. COP is heat delivered divided by electricity used. So electricity = Q / COP and ground heat = Q x (1 minus 1/COP).
Real COP changes with loop temperature and with how hot the delivered water must be, so a single fixed COP is a simplification. Radiant floors that run at lower water temperatures help keep COP high.
Why the ground beats the air
An air source heat pump must pull heat from winter air that may be well below freezing, so its COP drops on the coldest days. Ground loops see much milder temperatures, which is why federal energy guidance describes geothermal systems as among the most efficient heating and cooling options.