Although there are a few reasons (and articles) which generally
cover events similar to this. ~ Read through and see if this one
proposes some workable solution. If after several tries, maybe
look into other potential answers. Search engines help; my first
choice is duckduckgo. ~ Use some 'carefully phrased' ideas.
• If your Mac restarted because of a problem - Apple Support
https://support.apple.com/en-us/HT200553
You could try starting up in Safe mode, to troubleshoot effects.
• How to use Safe mode on your Mac - Apple Support
https://support.apple.com/en-us/HT201262
• About macOS Recovery on Intel-based Mac computers - Apple Support
https://support.apple.com/en-us/HT201314
[This offers ideas to further try things; including repair disk, reinstall macOS, etc.]
Sometimes if system has damages you may see 'partially loaded' desktops w/
images. Following give ideas on how to resolve those specific issues beneath.
• If your Mac doesn't start up all the way - Apple Support
https://support.apple.com/en-us/HT204156