There could be any number of factors causing your laptop to abruptly shut down, from a software glitch to a defective component.
First, try restarting your laptop and see if that resolves the issue. If it doesn't, try troubleshooting potential causes.
One possibility is that your laptop's battery is drained. Plug your laptop into an outlet and see if that resolves the issue.
Another possibility is that your laptop is overheating. Check your laptop's temperature and see if it's running hotter than normal. If it is, try cleaning the cooling fans and vents to allow more airflow. You can also try using a laptop cooling pad.
If you've tried all of the above and your laptop is still shutting down unexpectedly, it's likely that there's a problem with the hardware. In this case, you'll need to take your laptop to a technician for repair.