When you breathe, you inhale particles that are floating around in the air, like dust, allergens, bacteria or viruses. Usually these particles are trapped in the mucus that covers the mucus membranes of your nose and airways. Then tiny hairs called cilia transport the mucus (with the trapped particles) toward the throat. From there it can either be coughed out (also called “expectorating”) or swallowed.
But sometimes, particles like dust can irritate your mucus membranes or a virus or bacteria can cause an infection. This causes inflammation and results in extra mucus in your airways. This extra mucus is one of the ways your body tries to remove an irritant.
When there’s more (and thicker) mucus in your airways, your body may not be able to get rid of it in the usual ways (i.e. coughing it up or swallowing it). This is why you may start coughing more. Coughing is a way for your body to get rid of irritants in your airways or an accumulation of extra mucus that’s stuck inside your lungs.