This question is asked in many places, but usually remains unanswered.
We will try to give an answer here, but want to explain it in a slightly different way:
If we all walk around naked and someone pees on you, you are wet immediately… if you wear trousers, you still get pee through, but not quite as much, so you are better protected… if the urinator also wears trousers, the pee stays only with him and you don’t get wet at all…
Transferred to face masks:
If we all walk around in a closed room without a mask and someone coughs or sneezes on you, you will get droplets in your face and inhale them (potential risk to get infected with COVID19). If you wear a mask, you will still get droplets, but you will no longer inhale them. If the person sneezing or coughing wears a mask, the drops will stay with him or her and you will not get any.
That is why face-masks are useful for everyone indoors…
Remember, a mask is not meant to protect the wearer, but to protect the fellows around!