To avoid spreading germs and to protect from seasonal pollen
In Japan a surgical mask is generally used when people get sick. It is common to see many people wearing such a mask during winter. In Japan, people are sensitive about coughing in trains or in areas with a high number of people. So those who wear masks don't want to spread their germs and don't want others to be felt disturbed when coughing without mask on. Another common reason is to wear it during the season, spring or autumn. Many Japanese people suffer from cedar pollen in spring and you will find more people wearing masks between Feb to May every year.
It is easy to purchase these masks, there are many varieties, available in most convenience stores and pharmacies during the pollen season.