Typically every chip in a computer has a safe working temperature that, when exceeded can produce very strange results.
Every component in any type of integrated circuit will produce heat as a by-product of their operation and heat affects the performance of every last component. Resistors change their resistance very slightly when they get hotter, transistors leak more current as they get hotter and it is similar for every different type of component inside an integrated circuit such as a CPU. The problem is that in very large circuits all the tolerances of components can be very delicately balanced to produce specific circuit characteristics and when this balance is upset due to excess heat you can get changes in the way the circuit acts.
When the circuit characteristics change it can mean that wrong voltages get applied to crucial points and so the operation or the circuit can change. When this happens an operation that is invalid could happen and cause the processor to stall (as it is controlled by some very rigid logic) or output completely wrong data which the operating system or program is completely incapable of dealing with and so cause them to crash.
The reason everything is fine again after a reboot is that you have taken away the key problem, heat, and so the circuit is able to return to its correct operational state.
Prolonged excess heat can cause components to melt. Also, when circuits produce or sink excess currents or voltages due to functional changes caused by excess heat it can cause damage to them.
If you are regularly getting crashes due to excess heat then you need to either look at cleaning fans and so on or providing better cooling as the problem is only likely to get more frequent.