Magnets are made up of atoms. In normal environmental conditions, these atoms align between the poles and foster magnetism. When exposed to hotter conditions, the particles within the magnet are moving at an increasingly faster and sporadic rate. This jumbling confuses and misaligns the particles, causing the magnetism to be lost.
Heat demagnetization is also dependent on what types of materials make up a magnet. Some types of magnets such as Samarium-cobalt (SmCo) have higher heat resistance. There are also other types of Neodymium-iron-boron (NdFeB) magnets that are not as susceptible to heat induced flux degradation