Common causes of this are heat (have you looked inside and cleared out all the fluff, including cleaning the fans?), a failing power supply or maybe incorrectly seated memory chips.
If you've done this, then you need to do some investigation.
Try and make a note of how long the PC is in use before it shuts down, whether it shuts down when using a particular program etc .
If it is connected to the net, do you have updated anti-virus software running?
There are a number of things it could be so you need to try and supply as much detail as possible.