The answer to 'how does water heater work' is that a water heater uses either gas or electricity to heat water stored in a tank. The water is heated by a heating element or burner, and the heated water is then distributed throughout the home's plumbing system as needed. Water heaters typically have a thermostat to control the temperature of the water, and they also have safety features like a pressure relief valve to prevent the tank from bursting.
Water heaters come in different sizes and capacities to meet the hot water needs of a household. Proper maintenance, such as flushing the tank and checking the anode rod, is important to extend the life of the water heater and ensure it operates safely and efficiently.