N95 masks, fitted properly, do help prevent catching the virus. For a mask to be called N95 it has to be approved by the CDC. It’s specifically designed to block >95% of airborne particles. That’s why they’re recommended for caretakers at hospitals and frontline workers dealing with infected patients. Replaced every ~3 hours and worn in combination with goggles and ear protection, they minimize the risk of infection through mucosal membranes. They have also been in short supply.
Surgical masks do not prevent catching the virus, but they help sick people not to spread it due to the mask catching some of the spray droplets when they cough / sneeze