Near volcanoes, magma heats the surrounding rocks. When water percolates through these rocks it is heated. The hot water circulates to the surface to make hot springs. There are hot springs associated with Long Valley Caldera in California. Yellowstone is famous for geysers.
Geothermal energy uses the heat in the water to generate steam and drive turbines.
Hot Springs National Park is an example where the heat is non-volcanic. The water is heated by circulating deep beneath the surface and then rising along faults.