You need to isolate whether this is a hardware/electronics issue or whether its just bad software.
Format your computer to re install your system, and if it still shuts down quickly/randomly then your hardware/electronics is faulty.
If its a software issue, reset your PC to factory settings.
If its a hardware issue check every part of your computer. Here is a link of our excellent guides that can help you.
https://www.ifixit.com/Team/3286/USFT-BROWN-F14S3G2