The G4 had a design flaw that caused this. One way to verify it is to put it in the freezer for about 10-15 minutes, then turn it on while you leave it in. If It fully boots and acts normal, then yours is the known bootloop issue. Basically it's a bad solder joint that loses connection when it heats up.
You could try getting the motherboard replaced, but the problem is likely to pop up again with the new one. I personally just upgraded when my G4 was bit by this. I'm on the LG V20 and couldn't be happier.