That usually happens when Windows has encountered an error which requires a restart - in which case you should see a message along the lines of "Your system has recovered from a serious error". More details about this error can be found in the "Event Viewer" in Control Panel --> Administrative Tools. If, after the restart, you see nothing on screen referring to an error, it could be caused by a hardware component suffering from old age, wear & tear.
It used to happen on my previous 10-year old PC towards the end of it's lfe. Restarting with no warning and no error-messages either before or after the restart. Now it's in that great scrap-heap in the sky, but it served me well while I had saved enough money to replace it.
As the previous poster says, you can disable "automatically restart when an error is encountered". That will throw up a BSOD instead when a fatal error occurs. This is a blue screen with more details about what caused.
In my case however, I already had automatic restart disabled, but still got no blue screen. It would just restart with no errors and nothing in the Event Viewer either.