Is your Xbox well ventilated?
My Xbox one x was the worst Xbox console I ever had, and it’d turn off when playing certain taxing games that made it heat up fast. I could never play a raid in destiny after a bit cause it’d just shut off. Literally.
Anyway, you have to consider the series x is not immune to overheating and certain games can be too stressful on the console, causing it to just shutdown. Even without any notice or warning when turning it back on (that’s what happens on my one x… no “overheating” warning when I’d turn it back on).
Anyway, even if it’s ventilation is good, it’s possible the console itself wasn’t built the best it could’ve been (sometimes cpu cooling paste dries up fast or it wasn’t applied correctly, causing overheating issues) and you might need to get a new console or send yours out for repairs.
Hope this helps!