The data is sent throught the serial connection as I guess, so how does the program data and the normal data is distinguished transmitting through the serial terminal of Arduino ??
I think the short answer is the DTR pin of the serial connection is linked to the reset pin of the avr, so the IDE can reset the board before sending new code and so bootloader runs before already loaded code.
sorry for the late answer.