I had an issue with a system that would sometimes reboot without notice, and gave no information about why it needed to reboot (e.g. your computer shut down because of a problem...")
my suggestion is to backup using Time Machine if you have not done so already
How to use Time Machine to back up or restore your Mac - Apple Support
check the device for any possible hardware issues
How to use Apple Hardware Test on your Mac - Apple Support
if none are present
disconnect all external devices and reset the SMC
How to reset the System Management Controller (SMC) on your Mac - Apple Support
repeat 2 or three times
reset the nvram
How to reset NVRAM on your Mac - Apple Support
repeat 2 or three times
boot into safe mode
Use safe mode to isolate issues with your Mac - Apple Support
then reboot normally
if the issues persists use recovery mode to reinstall the OS
https://support.apple.com/en-us/HT201314
About macOS Recovery - Apple Support