The brake lights and the rear turn signals use the same bulb (filament).
The brake lights are wired through the turn signal switch.
When the turn signals are not in use the brake light circuit passes through a normally closed switch (integral to the turn signal switch) and brake lights function normally.
When one side of the turn signals is in use the brake light circuit for that side is opened and the turn signal circuit is closed thus flashing the bulb instead of the steady light during braking.
See attached schematic of the turn signal wiring.