For this, its important to understand how temperature increases in a star. Inside a stellar core, there are two forces that are balancing each other out to keep the star in equilibrium. The core pressure that is due to photons generated by chemical reactions inside the core forces the stellar atmosphere outwards (also called radiation pressure) while the gravity of the star pulls the star inwards. When these two forces become unequal, star loses its equilibrium.
Now, density of a gas is proportional to its temperature. If the density increases, the gas becomes hotter. Similar process happens inside a star. If gravity outpowers outward pressure, the star shrinks in its size and thus the density of gas increases. This increases the temperature of the star. To stabilize and get back into equilibrium, the increased temperature in stellar core leads to faster reaction rate in the core and thus more photons produced which increases the outward pressure and thus the balance is reached once again. Notice that the star wants to stay in equilibrium, hence in case of gravity>outward-pressure the core would like to increase its temperature so as to increase the reaction rate and increase the radiation pressure
In the second scenario, where radiation pressure outpowers gravity, the star starts to expand. Thus core density decreases and the temperature decreases too. Again, as the temperature decreases inside the core, the reaction rate decreases and as a result the radiation pressure decreases. The star starts to collapse again until the new equilibrium is reached. Notice again, that the star wants to stay in equilibrium, even when radiation-pressure>Gravity. The stellar core decreases its temperature so that number of photons produced decreases and the equilibrium can be reached.
For giants or supergiants, which are usually in their evolutionary phase where they experience high radiation pressure. Hence the stars have expanded a lot until the equilibrium was reached. Due to this large volume and stellar surface being far from the core, these stars tend to have a high mass-loss rate through stellar winds. As they have exapnded a lot since completing the Main-sequence stage, they tend to be cooler than the their main-sequence progenitor.
In case of white dwarfs, they are completely degenerate, which means that they do not any nuclear fuel left inside their core. Gravitational pull in balanced by electron degeneracy in this case. Since, the gas is as dense as it could get (as higher density might lead to neutron degeneracy seen in neutron stars), the white dwarfs tend to be hot.
It can kind of be noticed that, for stellar structures: Stellar surface area is proportional to its Luminosity and inversely proportional to its temperature. Generally speaking, as the star expands, the luminosity increases while the temperature decreases. Thus, supergiants which are in their expansion phase, are cool and Luminous and on top-left of HR diagram whereas white dwarfs, that have contracted to their limit are hot and dark or not luminous and towards the bottom-right on HR diagram.
