In fact, when you press the reset button, the controller resets and starts execution at the specified address (vector reset). In the case of Arduino, the address is at the top end of the flash memory containing the bootloader. If the loader does not see any traffic on the serial line (i.e., the incoming new program), it passes the execution to your program, i.e. setup(), loop() and it works. The program you load into Arduino is programmed in flash memory, it does not disappear so easily.
source share