Geothermal energy can be used to produce electricity by pumping cold water at high pressure into an injection well and extracting hot water, then passing through a heat exchanger. The rest is history. A must-read article by BBC Science Focus Magazine where electricity production using geothermal energy is explained relatively simple terms.
https://www.sciencefocus.com/science/how-does-geothermal-energy-work-to-produce-electricity/