Both things are true:
Anything starting from a scarf in front of your mouth greatly reduces the risk for other people to get infected by you. But it surely does not cancel it.
Anything starting from a scarf in front of your mouth partially reduces the risk of you getting infected by other people. But only a certain type of mask, corretly used, can reduce it so much as to cancel it.
Anything that does not filter 0,1 microns or smaller cannot stop the virus. It does not mean it doesn't protect in any way, as it eliminates bigger droplets or infected particles bigger than its nominal level, and even a scarf might be minimally helpful, but the viruses can pass right through.
What can protect you are respirators which can filter 0,1; they are the FFP3 disposable masks, or the reusable masks with FFP3 filters. HOWEVER: they lose half of their efficacy after 8 hours and NEED TO BE HANDLED CORRECTLY. The filtered impurities stick on the surface of the mask, so the mask should not be touched while wearing it, should be removed without touching it and should be thrown in sealed bags (or sanitized, if reusable, correctly disposing of the filter) after each (SINGLE) use.
FFP2 masks offer a limited protection against viruses, they also lose half their (already not fantastic) protective power after 8 hours and have the same issues with touching/handling.
ALSO, the mask ALONE does not protect 100%, as the eyes should be protected too and the contamination might come indirectly from touching infected surfaces and then touching the eyes, mouth, nose. To have a 100% cover, you should use protective shoe-cover, goggles, masks, face cover, double gloves, full (possibly air-tight suit, wearing them correctly, washing hands thouroughly before and after wearing the protections, disposing of the used items correctly and maybe removing all the clothes and cleaning them too before reverting back to normal life (as a friend who works with Covid-19 patients does each day).
100% level of protection is only attainable by medical personnel. What normal people can do is to reduce their risk as much as possible. This includes social distancing, washing hands correctly and frequently, not touching your face unless with clean hands and possibly wearing some form of protection in front of your mouth and nose and wash oneself and the clothes more frequently than usual.
It is important to notice that impurities can stick to the mask and to any surface, so cleaning/sanitizing/throwing away the exposed surfaces is paramount to avoid the infection; The mask might even become a danger, because if it is reused (ok, let's say... too much, but it technically should only be used once before disposing of it or sanitizing it) or touched too much it might favour coming in contact with nasty thing. Plus, the mask gives a false sense of safety, which is very rarely there, pushing people to relax on other form of self-protecting behaviours.
HOWEVER, most of the people will not get in real contact with infected people, so most of those over-precautions will be pretty much useless most of the times. The truth is, most people will only need something to cover their mouths and noses as a general protection, unless they are going to work in places where they know the virus is roaming.