Have you checked the CPU usage?
Launch the Task Manager by pressing the keys Ctrl + Shift + Escape simultaneously. Now click on Performance tab to view CPU utilization.
Do you experience the same in Safe mode?
You may need to change the Power Settings option to "never"
Here is a video which will help you to understand how to change the Power Settings to stop automatic shutdown.
https://www.youtube.com/watch?v=RXotaJbH85U
If required you have to right click on This PC and select properties, and then on the advanced tab choose startup and recovery. Untick the box in the system failure area that says "automatically restart".
Now note down what happens next time.