Properly-fitted, properly-donned N95 masks can only do one thing against respiratory viruses and that's lower the dose: it will NOT prevent infection
As a general measure to reduce the spread of respiratory viruses the evidence strongly suggests masking does little to nothing in the best of cases
For some viruses in some situations you may benefit from mitigating the dose of virus you're exposed to. For example, if you have a weak immune system and/or other comorbidities that place you at high risk of bad outcome from a respiratory virus and you'll be briefly passing through a crowded though otherwise well-ventilated area, that's one case in which wearing a mask might make good sense if you don't have other viable ways of mitigating your risk.
Think of it this way: when you get sick from a virus, that virus initially infected you with some dose. It's not just one viral particle that infects you, it's millions or trillions. Imagine getting infected by grabbing a doorknob with a small quantity of viral particles on it vs. having someone who is maximally sick sneezing directly into your open mouth a huge quantity of viral particles. Is there a difference between these two scenarios? Yes. The initial viral dose changes the dynamics of how the virus attacks your body. The smaller the viral dose, the more time your body has to mount a defense. As a virus infects you it begins to replicate. The quantity of viral particles grows exponentially. If this exponential growth starts from a small dose that's less-bad than if the exponential growth starts from a large dose. The smaller the initial viral dose the more time your body has to mount a defense, and the more likely your body is to succeed at defeating it before you get sick, or succeed at defeating it without you getting excessively sick.
Viral dose is surely only a very marginal effect that most people should not consider because it's a waste of time (among many other downsides). Though for some people in some cases, masks should be considered for the marginal benefits they have. As a general measure to reduce the spread of respiratory viruses the evidence strongly suggests masking does little to nothing in the best of cases (medical professionals properly trained in mask fitting, donning and doffing), and certainly does nothing when applied to the general population.
Study: “N95 Respirators vs Medical Masks for Preventing Influenza Among Health Care Personnel: A Randomized Clinical Trial” (full text archived)
Context: “Mask science in May 2021“