Your Mac was in sleep mode, not shut down. During the night, a USB device woke your Mac (hard to say why without known what the device is), then your Mac automatically reconnected to your wireless network.
You can wake a Mac with USB, Bluetooth, or network activity.