Its a common myth, that aggravates some of my historian friends to no end, that "plague doctors" with the clever bird-like black outfits, were A Thing during the Black Death, or in fact at any time prior to the 17th Century. They were not.
Here's a nifty meme made by one of them on Twitter.
Of course even in the 17th century when they did exist, there's no real evidence the fancy duds were particularly effective. It was just a fashion choice. One might imagine the mask was of some help with airborne diseases, but if so that was luck rather than skill.
Prior to the 20th Century there was not yet a generally-accepted germ theory of disease. Instead the predominant theory was miasma: The idea that there was "bad air", particularly around dead or diseased things. The reason for the masks was to try to filter the "bad air", and purify it by means of adding scents inside the mask, such as lavender. If it smells good, its now healthy, right?
Of course there's no known medicinal benefit to lavender scent proven by modern science, but in a world where the predominant theory of disease was miasma, blocking the existing air and making it smell better probably seemed like a smart idea to protect oneself.