Joseph G. Allen is an Assistant Professor of Public Health at Harvard and Director of their Healthy Buildings program. The New York Times has worked with him as well as several other professors to explain the process behind masks, to demonstrate that they do indeed work. In essence, particles get bounced around inside the fibers and trapped there. Interestingly, in the case of most masks, which are generally made of tightly woven cotton, the particles least likely to get trapped are medium size particles, as they’re big enough to be less influenced by surrounding air molecules yet small enough to not randomly make contact with the fibers as often. Large particles are most likely to get trapped, followed by small particles. Coronavirus particles are small and often get carried inside large particles, so they are in the two categories more likely to be caught by the fibers.
NY Times has created an infographic demonstrating the process. You can find that here: https://www.nytimes.com/interactive/2020/10/30/science/wear-mask-covid-particles-ul.html