This isn't magic, folks. The chances of you getting a disease that's spread through the air is based on viral load. That is to say, how MUCH of it are you around, how LONG are you around it, and how LIKELY you are to ingest it.
How MUCH has to do with how many people you are around are spreading it - being sick/infectious obviously increases that, so does not wearing a mask, so does coughing/sneezing.
How LONG is pretty simple - how long are you around it? If I'm walking thru the grocery store to get bread, even if I pass by someone who is breathing hard and is sick, I'm probably not going to catch it, because I'm not in contact very long. The checker, however...
How LIKELY is the part that has long been unclear about masks, in this case. They generally don't protect you very much in that situation, as you can get it on your hands, maybe in your eyes, etc, etc.
(I know "viral load" usually refers to how much virus you personally have in your body, but I think the analogy is close enough that I'm keeping the term going.)