I dropped my camera one day and it starting turning on and off from that day. There's numerous thing that can have caused why is it doing that.
1. Battery (rechargeable type - lithium ) this could be reaching its maximum lifetime change it.
2. The battery terminal where the + side of the battery should touch is loose and the spring tension is wont hold when the battery is inserted.
3. The battery doors is loose you may need to replacse the battery doors
I found mine got the battery not touching good enough on the terminals as it is supposed to have a constant and steady touch on the terminals positive side. What I did is I folded a piece of aluminium foil wrapper just thick enough to get a good push of the battery and it solve my problem. But this is only applicable for the built in type of battery. You place an aluminium foil wrapper behind the battery before you close or or slide the door in.
This is not recommended by the manufacturers. But it did the trick on my camera and it solves the lingering problem.