Because owing to its small size a virus penetrates a fabric mask more easily than smog particles. If you want to get technical, a surgical style mask doesn't do a great job of protecting against smog either, but it diminishes the amount of garbage you're breathing. N95 style masks are different. They do protect the wearer because when worn correctly they form a seal against the face and have a filter.
Mask wearing has now (ridiculously) become a political issue, so good luck finding one clear authoritative opinion, but I'm of the view that they've probably been of a slight benefit and slowing down the spread of disease. I'd guess the social distancing has done much more.