The virus is carried in tiny droplets in the air, usually from a cough or sneeze. Any mask that catches those helps prevent virus spread to and from you. So literally a bandana covering your face is going to prevent some. Of course it won't be as effective as a legit N95 or N99 mask, maybe it's only 10% as effective, but that is not the same as being totally ineffective.
Further, any form of masks provides a psychological aid to help people stop touching their face.
The main goal is minimizing leaks and making sure air flows through material. While a bandana would not be totally ineffective, there's room for innovation:
> A Hanes Heavyweight 100% preshrunk cotton T-shirt (made in Honduras) [...] was boiled for 10 minutes and air-dried
> A commercially available N95 respirator requires a fit factor of 100
> The prototype mask achieved a fit factor of 67
> We showed that a hand-fashioned mask can provide a good fit and a measurable level of protection from a challenge aerosol. [...] When made by naive users, this mask may be less effective because of variations in material, assembly, facial structure, cultural practices, and handling
Further, any form of masks provides a psychological aid to help people stop touching their face.