There could be various reasons why your Mac is shutting down again and again, such as an older software version, viruses and malware, problematic apps, peripheral device malfunction, or hardware issues. It's recommended to complete a proper shutdown procedure and check the Console for any error codes to identify the root cause [1]. Improper placement of the machine may also result in random shutdowns, so it's advisable to keep the laptop on a flat surface to allow proper airflow. If you suspect a hardware issue, you can try resetting the SMC or monitor the battery and replace it if needed. Additionally, you might want to consider using cybersecurity software like MacKeeper to optimize your device .