iMac turned itself on after power was cut
On the iMac, there's a setting under System Preferences > Energy Saver called Start up automatically after a power failure, which I'm guessing will be selected on your system, and hence would explain your computer's spontaneous rebooting.

If you don't wish this to happen in the event of a power failure, or the next time you turn off the power by accident, then uncheck that particular option.


Note: Screenshot taken on macOS 10.12.6 (Sierra)

As Tetsujin very helpfully points out in the comments below, there is also a button in the bottom right of the Energy Saver preferences pane labelled "Schedule...", which allows the user to regulate when the computer starts up, wakes up, or goes to sleep.  It would be wise to double check your settings there too.