This claim is false as masks have been proven to be effective at both reducing the amount of germs you breathe in as well as the chance of spreading a virus to others. According to a study by the International Society of Travel Medicine, “masks block some fraction of viral particles from dispersing from those who are infected and from infecting those who are susceptible and are understood to prevent disease transmission through this mechanism.” The CDC has a whole page about Masks and Respiratory Viruses Prevention, going into detail about how masks work and the effectiveness of different types of masks. Some masks are less protective than others, for example cloth masks are shown to be less effective in blocking germs you breathe in or out compared to masks like the KN95 or N95 respirators. Overall, however, masks do make a difference in disease transmission and provide some protection against spreading or contracting different viruses.
It is true that masks are used in a surgical setting to preserve a sterile environment. Infectious disease specialist Manisha Juthani, MD, told Yale Medicine “It is really important for me to wear a mask when I'm taking care of patients who have a respiratory virus that I could be at risk of getting and then potentially giving to somebody else.” So, masks may be used in multiple contexts, but that does not mean that they are only effective in the setting of a surgical site.
https://academic.oup.com/jtm/article/28/7/taab144/6365138
https://www.cdc.gov/respiratory-viruses/prevention/masks.html
https://www.yalemedicine.org/news/why-doctors-wear-masks
https://pmc.ncbi.nlm.nih.gov/articles/PMC8499874/