Abdominal surgery results in a painful wound that affects the abdominal muscles, which are important for coughing. The Lungs and respiratory tracts constantly secrete mucus that flows upwards to the Trachea then down the Oesophagus. The trachea is lined with a moist mucous-membrane layer composed of cells containing small hairlike projections called Cilia. The Cilia project into the channel (lumen) of the trachea to trap particles. The Cilia constantly move in a manner that pushes the mucus up to help clear the respiratory tract of pollutants, debris and bacteria. Here is a link to show the Cilia Movement:
Abdominal Surgery reduces the efficiency of the cough reflex due to abdominal wound pain, while the Anaesthetic results in an increase in mucus due to the upper respiratory tract trauma, with some anaesthetic drugs also increasing these secretions and suppressing Cilia movement. All that eventually results in secretions being produced at a higher rate than being evacuated leading them to accumulate and resulting in an increased risk of lung infection.