Cystic fibrosis is a genetic condition which causes an increase in thick mucus, which can become deposited in the lungs. The condition affects the body's ability to control the salt and water which moves in and out of cells. For this reason, the mucous becomes thicker (more viscous) and can become trapped in the lungs. The walls of the lungs are lined with cilia, which are hair-like projections that are involved in sweeping mucus out of the airways.
In cystic fibrosis, the increase in thick and viscous mucus means that the cilia are unable to sweep it out of the airways. This means bacteria are able to multiply and cause infections in the lung. This means that people with cystic fibrosis are more prone to lung infections.