|Check your BIOS for options such as POWER ON after line electric power is restored ( sometimes called AC back function ), Modem ring on/wake on LAN, Resume by alarm, PME event wakeup, Power on by mouse, etc. under Power Management Setup and disable them. |
These events all cause your PC to wake up surprizingly to external events.
For unexpected shutdowns, check if shutdown temperature is set too low in BIOS or if extreme heat is causing shutdown.
There may also be a program to shut down the PC on schedule at a certain time.