|That problem is typically due to one of the following: heat, system error, or malware.|
Unplug the power plug, open the computer case, and spray out all the dust and cat hair using a can of compressed air. You can pick it up at places like Walmart.Do not spray any fans for an extended period of time because you could wear out the ball bearings.
If the system flashed an error code just for a moment before restarting and you didn't get a chance to write down the details, read this article on disabling the automatic restart on system failure option:
What malware programs do you currently have installed and when was the last time you updated then did a full system scan with them? If you don't already, I suggest you also use Malwarebytes Free. It is only an on-demand scanner so it only works when you tell it to scan, but it's very good at detecting and removing threats.
Apologies if I don't respond to your reply immediately. I don't check this site daily.