Hot water heaters with tanks can run on fuel or electricity, and generally have 3 pipes for water transfer: one to bring cold water in, one to move hot water out, and a safety valve that releases water from the tank if the pressure or temperature exceeds safety limits.
The cold water pipe brings water to be heated into the bottom of the tank where the heating elements are located. As the water warms, it rises to the top of the tank to be removed on demand by the hot water pipe.
If hot water is not being used, it sits in the tank, being continually heated. If the hot water is used up, there can be a delay and you may need to wait for the tank to fill again.
Typically the water supply line splits soon after the service entrance, one side to all the cold water demand, the other to a heater. The cold water and hot water are of roughly equal pressure, and demand is met when a valve is opened.