Samsung Galaxy S4 will not boot, turns off after 2 seconds
This is the infamous power button problem. I had this too. There are some guides that speak of cleaning the power button, but for me I found this rather rough solution to be effective.


SOLUTION: Galaxy S3/S4,S5, Note, Tabs ALL Samsungs (not Booting Up? Keeps Rebooting? Not turning on? (just hit the phone HARD on the power button)


UPDATE

Alright guys, so I'm back -- it's 2016/04/25. My S5 just broke so I'm downgrading until it comes in the mail. Googling for the same problem and I found my own answer. This time hitting it hard didn't work. So I sprayed the button liberally with DeoxIT D5 and violla, back in business. Hold the phone button side up and just soak it!