Fighting bad air with good smell
Plague doctor masks were commonly packed with dried flowers like roses and carnations, herbs like lavender, peppermint, and cloves, and sometimes camphor, myrrh, or a vinegar-soaked sponge. The prevailing medical theory of the time held that plague spread through miasma, foul-smelling, corrupted air, so a beak full of pleasant, strong-smelling material was believed to purify each breath before it reached the wearer.
Right mask, wrong reason
Miasma theory was wrong; plague spreads via the bacterium Yersinia pestis, carried by fleas, not bad-smelling air. But the strong-smelling contents of the beak, camphor and vinegar especially, may have genuinely deterred fleas from approaching the doctor's face, and the mask plus the rest of the protective costume likely did offer some real barrier against bodily fluids and respiratory droplets. Protection, by complete accident, for entirely the wrong theory.