Usually the micro is put into some kind of programming mode. With flash pic's it is with 13 votls being applied to the MCLR pin. Then data is clocked into the flash memory with a SPI interface. New generation pic's can rad and write prigram memory directly. This is useful for stroring constant data like strings and other values that won't change often, It makes the eeprom data memory redundant. Anyway, you can actually rewrite your program memory space if you know what you are doing. For example you could send instructions to the pic from the computer by USB or RS-232 or whatever. The pic jumps to a piece of code that takes data that has an address field and a data field and places that data into program memory, thereby changing it's programming. Once and end of data being downloaded condition is met the pic could jump to its reset vector, memory location 0 and start running the new program. This could even be done over the internet. I believe Microchip has an application note on it, but you'd have to check that out.