First thing you need to do is post your computer setup information otherwise it is just guessing at your problem
Normally when a computer shuts down by itself is due to Overheating, Power (PSU Issues), Overclocking, Defective hardware, Driver issues at times, or incompatible hardware.
Download OCCT and run the GPU Test and see if anything is overheating. Also check the PSU Outputs while under stress. The 12v and 5.0v should be with -/+ 5% tolerances.
In fact run the OCCT PSU Test and CPU test to see if your computer crashes or fails the Stress tests.