You can use a programmer to program stuff into the microcontroller, by simply writing data into the Flash memory inside the microcontroller.
If you buy a microcontroller, as a standalone chip, it's empty. You use a programmer connected to a couple pins on the microcontroller to program data into it.
Arduino boards have a bootloader preprogrammed, a very small application which just checks if you want to program something into the micro, or starts the code that was previously uploaded.
This way, the new code can be transferred into the microcontroller through the usb connector and the bootloader takes the data and puts it into the microcontroller flash memory then launched it.
You can program the bootloader and basically replicate an arduino or you can skip the bootloader and program your code using serial and a custom pin header.