The uploaded Arduino sketch has in the part provided by core a code which waits for a 1200 baud connection on USB. If a 1200 baud connection is established it resets the board to bootloader. The bootloader then starts the com port and waits for the upload.
To reset a board which has in boards.txt upload.use_1200bps_touch=true
Arduino IDE opens a 1200 baud connection to the board, then detects the new com port and doesstart avrdude for the upload.