The answer to 'how does thermostat work' is that a thermostat is a device that monitors and regulates the temperature in a home or building. It does this by continuously measuring the temperature in the space and turning the heating or cooling system on or off as needed to maintain the desired temperature set by the homeowner.
Thermostats work by using a temperature sensor, typically a bimetallic strip or a thermistor, that expands or contracts with changes in temperature. As the temperature rises or falls, the sensor triggers the thermostat to turn the HVAC system on or off to keep the temperature within the desired range. Many modern thermostats also have additional features like programmable schedules, smart home integration, and remote access to allow homeowners to better control their home's temperature and energy usage.