Bacterial superinfections can develop from head colds that migrate into the lungs. But one would think a doctor would normally at least wait until it has, before prescribing the azithromycin.
Viruses can crap out the immune system thereby enabling opportunistic bacteria to multiply causing a secondary bacterial infection in the respiratory tract. These secondary infections can cause bacterial pneumonia quickly when the immune system is already compromised fighting off a viral infection. Antibiotics prevent this from occurring.