You can find the previous shutdown cause on your Mac by running the following command in Terminal
log show --predicate 'eventMessage contains "Previous shutdown cause"' --last 24h
If Mac has shutdown in the time specified, you should see messages such as Previous Shutdown Cause:
followed by a number. The number is a cryptic shutdown code representing the cause of the shutdown.