Hello rohan-aroskar,
We would like to see how we can help you with your Mac powering on unexpectedly. Is the Mac connected to an external connections when this happens? Are you using Bootcamp with the Mac? Follow the steps in this link, though the isue differs from yours a little, the steps shouls help to isolate the issue: If your Mac restarted because of a problem - Apple Support
"Check peripheral devices first
If you don't have any devices attached to your Mac, skip to the next section.
- 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 the internal RAM and third-party hardware.
- If an unexpected restart doesn't occur, turn off the Mac and connect one peripheral device at a time until an unexpected restart occurs."
Cheers!