Please do try these troubleshooting steps that may help.
- Start by doing a hard reboot, remove the battery and unplug the AC adapter then press and hold the power button for 20 seconds then try booting it up again.
- If the same problem will persist do test it without its battery and see if it will stay on with just the AC adapter connected.
- If it does stay on that means the battery is already faulty.
- If it doesn't stay on proceed with reseating the RAM's, remove them all for couple of seconds then put them back in making sure everything is seated properly.
- If it will still shut down you'll need to open your laptop and clean the inside of it, remove the dust off the fans and apply new thermal paste on the GPU and CPU.
- If all these will not work you'll need to sent it for a repair specially if it's still under the factory warranty.