Some wireless devices can interfere with your Xbox,like cell phones and wireless laptops.Also at times,take a soft cloth and carefully wipe off the power button.Sometimes grease or oils from your skin or dust can cause the power button to falsely report as pressed
The shutting off part depends on if you have the Auto-off setting enabled.When your console is inactive for a certain time,it'll turn itself off.
To fix that follow the link below
I hope this helps in any way.
Cell phones and wireless laptops wouldnt cause the xbox to turn on and off. It could be a power supply issue. Try to find a buddy with an xbox and borrow his power supply and see if it works if KageNoRyu's advice doesnt help.