All three Samsung Galaxy S2 phones on my account have this problem. My phones are less than 2 years old. The first phone did this about 6 months ago and never recovered; the second phone (one I'm still using) did this back in August for a few days, then recovered and I'm still using it today but it's got other problems like 10 second lag when calling or texting. The third phone started turning on and off about 3 weeks ago. This third Galaxy S2 continues to turn on and off. Basically, all 3 phones we bought have this problem. We presume it is some planned obsolescence sent via Samsung's OTA updates in order to encourage us to buy newer Galaxy S model phones. I wish there was a way to block the forced updates. We definitely will never buy Samsung phones again.
TIP: If you need to recover photos, put an SD card into your phone. When you turn your phone on, you have about 10 seconds before it shuts off again. Quickly unlock your screen, turn on GPS, then Bluetooh. When the Bluetooth screen pops on, let it stay on Searching for Devices for a few minutes. This may let you access your phone. It worked for me once, now it won't work again and the phone just turns on and off like before.
Good luck with your recovery efforts!