Screen suddenly turns off randomly, not controllable

Make sure you don’t have any magnets near your MacBook’s “lid closed” magnet sensor ("hall effect" sensor). You could be accidentally tricking your Mac into thinking you closed the lid and want it to sleep.

Even setting a running MacBook on top of a closed MacBook is enough to cause the running MacBook’s hall effect sensor to detect the closed MacBook’s lid magnet and go to sleep.

The last person I suggested this to realized he had a tablet stylus on his desk near his MacBook and the stylus had a magnet in it. Also watch out for magnetic clasps in watch bands and bracelets, magnetic “health” bracelets, etc.

This answer might not end up being the case for you, but I’ve seen this hit enough people that I like to post this answer anytime someone asks about MacBooks randomly sleeping or screen-blanking