Infections like Coronavirus are spread when an infected individual coughs an explosive aerosol which contains infected virus.
It is easy to imagine somebody close to this cough either breathing the virus directly in or having it going into their eyes. This is why medical staff and close relatives have a higher risk of infection. It is also easy to imagine how a mask or covering with a hand can prevent this infection from spreading.
People who have symptoms should wear a mask and cover the nose and mouth when coughing.
“Catch it, Kill it Bin It”
In practice most of the virus from the cough above goes onto surfaces or the floor and the greatest risk of infection is to pick the virus up on fingers which then make contact with the nose or eyes.
A good illustration of this point is that public health doctors focus on individuals sitting within two rows of an infected traveller on an aeroplane or train. This is the distance of greatest risk.
The role of masks in individuals without symptoms and outside of high risk situations is controversial and to some degree is a matter of personal preference (link to WHO's analysis).
Hand washing remains the single most important preventative measure for individuals without symptoms.