It bends because it is made of two metals that are joined together, something called a bimetal switch. One metal (usually brass) expands quickly when heated, while the other expands much more slowly. This difference causes the switch to bend toward the low-expansion metal.
Bimetal switches are used in other appliances that switch electricity on and off to keep their temperatures even, like irons and refrigerators. The thermostat that regulates the temperature of your home by turning your furnace and air conditioner on and off also uses a bimetal switch.