Viruses are very small:
Virions, single virus particles, are very small, about 20–250 nanometers in diameter or 0.25 to 0.025 of a micrometer.

https://courses.lumenlearning.com/boundless-microbiology/cha...

The flu virus is typical:
...the flu virus is .17 microns in size.

https://www.envirosafetyproducts.com/resources/dust-masks-wh...

Masks work by trapping flu particles.
The 95 in an N95 mask is shorthand for "this masks traps 95% of particles of size .3 microns.

There are also N99 and N100.
N100 trap 99.7%. N100 when it is used in an air filter is called HEPA which I believe stands for High Efficiency Particle Attenuator or Arresting.

There is also a level above that found mostly in Europe called ULPA which pushes the decimal out further to 99.9997% . All of these aarea measure of the masks ability to trap particles of 0.3 except ULPA which is a measure of trapping particle 0.17

https://www.globalspec.com/learnmore/manufacturing_process_e...

Masks are matted fibers designed to trap particles on their fibers. They do this using 3 mechanisms which all masks share- diffusion, impaction and inertial impaction.

Diffusion happens when a particle is so small it is in Brownian (random) motion. These particles are trapped because they constantly change direction randomly as they pass through the mask and eventually run out of luck trying to dodge fibers. Such particles are less than 0.03 microns in size. (I should inject here that even though virus are smaller than this, there's more to the story as detailed below).

Inertial impaction happens when a particle is larger than .03 and owing to its size and momentum cannot change its direction of travel fast enough to stop itself running into a fiber.

Impaction happens when a particle comes within 1/2 of its radius of a fiber and touches it, becoming trapped. This is the most difficult size of particle to capture (as it happens) and that's why its the reference particle size for safety masks.

In the above I acted as though the particles were "trying" to avoid being trapped, but of course that's just a stub for the underlying physics off motion and magnetic attraction/repulsion which underlie these facts.

If you want to DIY some sort of mask to reduce your exposure, you have to consider that the weave of most cloth is far far wider than .03 and anyway not in layers (a cloth like yarn is the exception to the second property).

Just guessing but rags scarves etc lack the required fiber density to function as safety masks. It is possible that the virions would sail through them even under Brownian motion. But that is not really how virions are transmitted- they are transmitted mixed in with saliva particles which are hugely larger than the virions themselves. The size of a particle of saliva in a sneeze was examined here- tldr: a bimodal distribution of sneeze particle size all over 50 micrometers.

https://royalsocietypublishing.org/doi/full/10.1098/rsif.201...

Some other studies have put the size as small as .35 micrometer.
https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4676262/

What is really astonishing is how fast the particles travel- 200 MPH.
https://www.livescience.com/3686-gross-science-cough-sneeze....

https://www.texairfilters.com/what-happens-to-the-particles-...

So all in all we can say this-any mask covering is better than no mask because it's an odds game with virus particles and saliva.

The less able you are to breath through it, the better it functions as a barrier.

Ordinary cloth is just not woven tightly enough to substitute for a p95 mask.

If you had to choose between multiple layers of x number of fibers and a tighter weave of the same fibers, it might be better to go for a tighter weave because even though individual virions would travel under Brownian motion, that's not how a spray of sneeze which is the transport mechanism of the virus is going to travel.

Some sneeze particles containing virions have a particle size of 5 microns and will stay aloft in a still room for a long, long, long time. If someone sneezes and three minutes later you walk through where they were, you could very well become the unknowing, unwilling next host of the virus.

That last - horrifying - fact is one of the the reasons why they're telling people to maintain social distancing and just stay home.