Pool heaters work by taking cold water from the pool, heating it, and putting it back into it. They typically do that in one of two ways. A natural gas heater has a burner to heat the water, and an electric heat pump heater uses an evaporator coil that turns outside air into warmer air that it can then use to heat the water – a kind of reverse air conditioning. Heat pumps are slower than natural gas ones and work best in warm climates, but they're more efficient and tend to be cheaper to run.
There is a third kind, the electric immersion heater. It has a tank with the same kind of heating element you'll find in a tea kettle. However, such models tend not to be very powerful and aren't suited to large volumes of water. They're also much less efficient than heat pump models.