This could be caused by 1 of 3 things.
1. Your power supply is failing and needs to be replaced
2. Your computer is overheating or thinks it is
3. Your power button could be sticking
The last one is the easiest to check.
-when you press the power button does it stay in or does it pop out as normal. If it pops out move on
-Remove the size cover and check for excessive dirt build up
--If yes, use canned air (do not hold can at an angle as it may cause the propelling liquid to come out and damage components)
-When you power on the computer look inside does the fan mounted on a big circuit board (motherboard) spin
--If it does not the fan may not be plugged in all the way or just bad and you will need to replace it
-Check the BIOS, a lot of BIOS will show you the computer temp
--This will be accesses from the first screen you see with text (Usually Award or Phoenix BIOS)
If you have tried all this I would replace the power supply
-You can buy them from Best Buy for about $40 and return if it is not the issue.
Here is a nice guide on how to install power supply