Well,
Most uC's have built-in FLASH memory to store boot-up code or embedded software. If the uC does not have a built-in FLASh, then one will be there on the board with the reset vector connected to it, so that at power up after reset, the controller reads from the flash and loads the software. When you program/burn your code into a uC, what happens is the following:
1. The FLASH in the uC/on-board is set into the erase mode and all existing contents of the flash are erased.
2. Next, it is set in the Write mode.
3. When the hex file is sent via JTAG/USB/UART/etc, it is serialized and sent to the flash keeping in mid the flash's write protocol ,ie, read/write strobe, address,data,etc.
4. This the data is written into the fLASH memory.
5. When the operation is complete, a signal like an interrupt is generated to let the user/application know that the programming is complete. If there are any errors durning the burn process, and error signal is raised.