On Windows 11 (or if you are still running Windows 10), you can use these three ways to find out why the computer shut down unexpectedly using the system event logs.
Windows 11/10] Troubleshooting - Automatic Shutdown/Restart Issues, Official Support
SOLVED] PC Randomly Turns Off - What to Do? — Auslogics Blog
How to Use Safe Mode to Diagnose a Problem in Windows 10 or Windows 11
How to find out why your PC shut down for no reason on Windows 10 and 11
4 Easy Ways of Shutting Down your Laptop
Shortcut keys for shutdown: How to shutdown laptop/ PC using shortcut keys
How to Shut Down Your Windows PC Using Keyboard Shortcuts
How to Find the Cause of an Unexpected Shutdown on Windows 10 [Tutorial]
Windows 11/10] Three ways to turn computer off - Shut down , Sleep, and Hibernate, Official Support
Windows 10 tip: Take full control over how your PC shuts down
Fixed] Memory Management BSOD Error on Windows 10/11
Windows 10 Help Forums
How to Shut Down or Restart Windows 11