One of the common problem would be overheating. When your motherboard detects that the computer is running at an unsafe temperature, it would shut down the computer to cool down.
Perhaps your computer has too much dust inside and preventing the ventilation. When that happens the best solution is to clean the inside of the case and fans. Use a can of compressed CO2, that helps you clean up the dust much faster than a brush.
Another problem would be the power supply is failing, but if you have that problem, the computer would restart more often.