Computer may restart due various reasons.
The most frequent problem is the CPU cooling fan, if the CPU cooling fan is not working properly then it will restart the machine, in order to protect the processor from further damage.
Sometimes if you are using more memory and the system doesn't have enough memory or the RAM is damaged it might restart the operating system
If the system is in a very hot environment and it might restart the machine to protect the system.
If you have harmful system virus present in your system will also automatically restart the system.