First, does your computer turn back on?
Are you able to start your PC again?? If not there might be many reasons why your pc isn't working like maybe the power switch is not well attached to the motherboard, or have you checked your processor fan? Many computers will automatically shut down if the processor fan stops or any other hardware component might have got damaged like RAM, MotherBoard, or your Processor.
If your computer shuts down randomly, and when you restart it shuts down even faster, then your processor is overheating and it's shutting down to prevent damage. Solution: clean all the dust inside, make sure all fans are working, and if possible get new thermal compound for your processor.