|A computer restarting/shutting down by itself is usually caused by these few things.|
1.) A hardware problem or defect, if the computer shuts off by itself it could be the CPU (Central Processing Unit) overheating, or the PSU (Power supply unit) failing.
2.) A driver problem or newly installed software.
Do you get a Bluesceen Of Death (BSOD?) if so what is the Error code associated with this bluescreen?
Usually a blue screen of death will have a stop code which you can search up on the internet and it may also tell you the name of the driver/file that is causing the problem.