Mac spontaneously restarts
I'm not sure what is causing it, but it sounds like a hardware issue, or that the power outlet the machine is plugged into may be faulty. 

You can try going to the Energy Saver preference pane and unchecking Start up automatically after a power failure. If the computer really is shutting down and restarting this may help you find out.

If it is shutting down, it may be:


Faulty power supply
Faulty power outlet or another electronic device complicating power in that outlet
Overheating