I think when you perform Steps 3 and 4, it is part of the larger loop that handles all the other stuff.
So the MODE button status is polled and once it exceeds the time set, wifi credentials are erased and the USB Serial port is enumerated (if it has not) and wait for user input.
After that is done, the core would enter the main loop (loop()) to run user firmware.