IMac turned itself on

I left my computer sleeping but turned off the power by accident. Hours after the power was turned back on the computer booted itself up. It is plugged into a UPS. I don’t understand how this could happen.