Viruses don't travel alone. The current understanding is that they are almost always contained in body fluids. That if they are not protected by some sort of biological goo not created by the virus itself they die. These virus containing fluids can form an aerosol when people cough or sneeze that can drift on the air for a good distance. If you breath these droplets you get the virus. If you stop contact with these droplets by preventing them from being breathed or from physical contact after they are on surfaces you have stopped the virus.

Masks may be more effective at keeping the disease contained if used on an infected individual but they are not ineffective when worn by the healthy person. Ideally both would wear them. there is also the simple fact that many diseases can be spread by people who don't, may not ever, show symptoms.

Putting a mask on sick people can help. But seeing as they may have been shedding virus for 24 hours prior to their showing symptoms your closing the barn door after at least some of the horses have left.