First step I suggest - clear CMOS. If your motherboard doesn't feature a clear CMOS button/jumper, then just remove the tablet battery from the motherboard and leave it for an hour (a day is ideal, but sometimes 5 minutes also works). This'll reset BIOS settings and hopefully clear any corruption it may get.
Second step is to remove parts. Reduce the system to just the motherboard, 1 stick of RAM, the CPU and the PSU (and a GFX card if it doesn't have an integrated GPU). No drives or USB devices at all. If it stays stable for, say, 10 minutes, then start plugging things back in one by one (main drive first, to see if Windows loads, then extra RAM, etc). This step has somehow fixed many computers I've handled which don't start up or shut down randomly (although some did have to RMA).
While you're at it, you should also look at the capacitors around the CPU socket and see if any of them look bulging or even blown. It's not likely and I've never seen it happen, but apparantly it happens to a lot of people and is a sign that the power phasing on the motherboard has failed. Otherwise, it may be a PSU failure (one or more of the 12V rails, if it has more than one, may have failed and no longer produce a stable output).
One more possibility is a corruption in the boot sector in the drive, but that tends to just randomly reset whilst Windows is loading, not shut down. Shutdowns indicate a power failure most likely.