A mask can stop you touching your face with contaminated hands and fingers, and it can prevent you spreading whatever virus you happen to have through coughing and sneezing. It won't stop you from inhaling airborne virus particles, but that's not how most viruses spread anyway.
I don't touch my face when I'm outside, and I guess nobody is wearing mask inside.
Masks are good so you don't spread possible latent infection. Also when you are taking care of infected person, the infected person should wear mask, not you.
The virus cannot exist in air by itself. It is only spread through droplets. You you are wearing the mask, and it's moist from you breathing, if such droplets land on the mask, it's the same as if you didn't have any mask. Some suggest it's even worse.
But if the mask stops most of droplets the other person coughs out, it has major effect (though it's not perfect).
Respirators is another thing, they can have some effect, based on their class. They have different construction, typically have exhale valve, and much better fit. Some of them can look quite like simple masks. Also they have to be used with goggles, as eyes are just as good entry point.
Think about it. What kind of doctor wears mask ? Surgeon. It's not for his protection. He doesn't want to infect the patient.
What do wear doctors treating infected people ? Full body suit, respirators and goggles.
In Japan, wearing mask in public is not mark of you being paranoid, but mark of good manners. It says 'I don't know if I'm infected, but for your safety, I'm wearing this mask'. Usually it's done if you go to work with minor cold, but it works just as well with coronavirus.
Coughing into your handkerchief work in similar way. But can you pull one in time ?
And of course, if everybody is wearing the mask, based on panic or not, it does help. People with masks spread less. That's very unlikely in western society though.