Why my imessage and facetime button turn off by itself?
When the registration cannot complete the software indicates that failure to you. Basically when you tap "on" the device undergoes a handshake and registration over the network to set up the cryptographic keys that Apple will then use to uniquely encrypt the data going to that device (and that device only) using your AppleID/iCloud credentials to build up the keys.

Apple has a troubleshooting article:


https://support.apple.com/en-us/HT201422


It's always best to go through those articles slowly, and in order (especially when it says restart - you really need to restart).

I've seen the date be wrong on the iOS device, so if you like guessing on hunches, you could sign out of iCloud and then toggle the "set date/time" setting in General and be sure the clock is correct on the iPhone. Then you could try enabling iMessages.

Lots of things can mess this up including:


two factor authentication / unique passwords (in that your iCloud password isn't the same password your iMessage/FaceTime password)
OS running out of space or iPhone needing to be restored
problems at Apple's end for all iMessage users http://www.apple.com/support/systemstatus/
carrier not sending SMS validation message to your iPhone
problems with your AppleID