A restart with no warning is the system's emergency response. When something goes wrong at a level the operating system cannot recover from, cutting power and starting again is safer than continuing.
Heat is the most common trigger. Processors have thermal limits, and when cooling cannot keep up the hardware protects itself. These restarts cluster around demanding tasks: games, video export, long builds.
Power delivery is the second cause. A failing supply, a loose cable or a battery that cannot sustain peak draw makes the voltage sag for a fraction of a second, which is long enough to reset everything.
Software causes exist but look different. A faulty driver tends to restart the machine at the same moment each time, such as when a specific device is used, rather than under general load.