Nothing stops 100% of viruses. But if everyone wears something -- anything really, even a handkerchief or a piece of toilet paper -- that reduces the chance of infection by 50% for example, there will be only half as many infections compared to the case where nobody wore anything.
After a few rounds of 50% reduection, even a mediocre mask will be able to reduce the number of cases by 99%. And that's all we need to prevent hospitals from being overwhelmed.