You are spot on re "... protect others from someone who is sick ..."
The dust masks you find at the hardware, from what I'm able to tell when compared to similar masks available for one time use on a medical unit are w-a-y better than a cotton scarf or cotton home made mask if you are trying to protect yourself from a spit-spray cloud left hanging in the air by someone who just sneezed. Cotton seems way to porous.
But, fit is everything.
The quandry is that an infected individual would wear a mask to prevent expelling mist or droplets into his/her surroundings. A non-infected individual would wear one to prevent inhaling "large" droplets (a relative term, ref the link in my post that follows). I typically worn this type of mask to protect me when entering a patients room who had a respiratory disease (e.g., the flu). A care giver would wear an N-95 (or even an N-100) to protect against 3 micron and smaller infections particulates.
BTW: I exchanged texts with a critical care (i.e., ICU) nurse friend who works at Sutter Auburn Faith hospital. The nurses over there are in dire straits. She said "We are rationed 1 surgical mask per day (worn 24/7 except meals) and N-95 is for 1 RN per shift. No one is allowed in COVID rooms except RN, MD, or RT" (RT=respiratory therapists). If anyone has a stash of N-95s or a group can make a bunch of surgical masks (shop towel material?), maybe it could help those on the front lines over there.
One style of surgical mask. Note, that with this and similar designs, after securing the lower tie, the pleats are pulled apart as the mask is pulled up over the nose.