A computer can reboot for a number of reasons but first thing is to stop it doing this - To see what the error was you can change the default behavior by right clicking on “My Computer” and choosing “Properties”. Goto the “Advanced” Tab and under “Startup and Recovery” press the “Settings” button.
Under the “System Failure” box there will be a checkbox saying “Automatically Restart”. Untick this box and click Ok.
Next time the system has a failure it will show the Windows error blue screen (also known as BSOD, Blue Screen of Death) and it will have an error code, grab a piece of paper and write this code down. It may look something like this: Stop 0x0000000A or IRQLNOTLESSOREQUAL
You can check out the error code(s) via Google Search
Another cause could be overheating.