What I did was turn off the screen timer option off and I no longer have the problem.
The environment around my computer is good. There is space and I clean the dust off the exterior often. The interior does need cleaning, and I do it occasionally but it is not a regular thing.
I believe that problem had to do with software and not hardware.
I think this issue could be related to hardware kindly check the output voltage of the smps mostly if smps creates voltage issue so your system will shutdown by itself to safe it.
Or maybe your cpu getting too hot to run so it get shutdown. Or try ram maybe not working correctly.first try to observe tge cpu temp and then the otger stuff.
And kindly provide some hardware details so we can understand better your system.