STM32 Built-in Bootloader
All STM32 MCUs have a built-in bootloader which is stored in the internal boot ROM (system memory). This boot ROM is programmed by ST during manufacturing and can not be altered. The main purpose of the boot ROM is to allow applications to be written to the internal flash memory.
Depending on the exact STM32 device family, the internal boot ROM will allow flashing using a variety of different methods:
There are a number of different bootloader activation patterns described by ST in the reference documentation and in order to fully understand the operation of a specific STM32 microcontroller, it is necessary to consult that documentation. In most cases however, the Boot0 pin is the most interesting one. If left dangling or tied to GND the device will boot normally, but if pulled high the device will bootstrap from the internal boot ROM.
The various boot modes of STM32 microcontrollers is described in details in AN2606 Application note - STM32 microcontroller system memory boot mode.