Hey,
Try performing these basic troubleshooting steps:
Peripheral Problem
- Shut down your Mac.
- Disconnect all peripheral devices, such as hard drives or printers. If you have a desktop Mac, make sure that only a display, keyboard, and mouse or trackpad are connected.
- Turn on your Mac.
- Use your Mac for the amount of time that it would usually take for an unexpected restart to occur.
- If an unexpected restart occurs, follow the steps to check for a Hardware error.
- If an unexpected restart doesn't occur, turn off the Mac and connect one peripheral device at a time until an unexpected restart occurs.
Start in Safe Mode
Start up an Intel-based Mac in safe mode
- On your Mac, choose Apple menu > Shut Down.
- After your Mac shuts down, wait 10 seconds.
- Restart your Mac, then immediately press and hold the Shift key.
- Release the Shift key when you see the login window.
- Log in, wait for it to restart unexpectedly.
- If it doesn't restart, then it's mostly a software issue.
- Open System Preferences, go to Users & Groups
- Choose your Account, then choose Login Items
- Click the Lock in the bottom left of the System Preferences window and enter your Password.
- Uncheck all the apps that are lined up for Startup
- Press the lock again to confirm changes.
- Open Finder, then go to Applications.
- Move any apps that you don't want into the Bin by right-clicking the app and selecting Move to Bin
- Restart normally and check if your Mac works.
Hardware Problem
Your Mac might have a Hardware issue. To check for Hardware issues, try this:
- Turn on your Mac, then immediately press and hold the D key on your keyboard as your Mac starts up.
- Release when you see a progress bar or you're asked to choose a language.
- Run Apple Diagnostics and post the results here.
I hope this helped. Please try all of these steps.
Reference links:
Start Apple Diagnostics: https://support.apple.com/en-us/HT202731
Startup in Safe Mode: https://support.apple.com/en-in/guide/mac-help/mh21245/mac
If your Mac restarted unexpectedly: https://support.apple.com/en-in/HT200553
Reply to this answer with the results or if you have questions.