Computer randomly shut down to prevent damage from overheating. This problem generally comes due to the power supply, malware, overheating or driver issues.
Second one is the most common reason when you are playing a game, Computer is overheating.
There are several reasons when your you find something went wrong with your Computer. But, overheating should be your prime suspect.
Both hardware and software related that leads to the Computer problem.
Hardware related issues
Software related issues
Malware/Malicious programs issues
Memory related issues
Faulty or out-of-date drivers can lead to problem in Windows.