This sounds like a hardware problem, but before such conclusion can be drawn, we must troubleshoot the problem to avoid unnecessary replacement of hardware components.
The best place to start is by asking windows why it decided to shut down.
Most likely Windows doesn't know either (if the hardware malfunctioned, windows didn't trigger the shutdown itself)
But if Windows knows what happened, it can be of great help.
unfortunately, at this time I also don't know where exactly this information can be found. I hope other super users can point that out.
There are probably a few error logs we can look at, however I don't know which that would be or where they would be, so I hope someone else can post about that.
Now we can also troubleshoot the hardware a bit.
sometimes a computer shuts-down suddenly to prevent damage from overheating.
Often, one can set a temperature value in the BIOS at which the computer should shut down.
You could start by holding your hand next to your PC where the air is blown out, and felling if it seems unusually hot. If it does, there is a change your PC is overheating. If it feels somewhat cool, maybe the fan is not even working, or there simply is no overheating.
A more direct approach would be to download software like HW Monitor from CPUID. This software can tell you much about the temperature of your hardware and sometimes also about the fans. There is a freeware version which can do the trick.
We could also be dealing with faulty memory (RAM). You can download and install a program called memtest86+ for this (I recommend the memtest86+ over memtest86, yes there is a difference)
This software is directly installed on an empty USB flash drive. the drive is than bootable, which means you have to reboot your PC, and load the software from the flash drive to run before windows starts.
If you run memtest86+, it will simply test your memory and report any errors found (if there are any).
If your memory is indeed faulty, it most likely needs to be replaced.
this are only some random attempts to troubleshoot the problem. It is very hard to give a fitting answer to your question without more information about the problem.