Surgery severely changes the body's normal physiology. Any serious trauma---including major surgery---causes a great deal of inflammation, activation of the body's systems for dealing with infections and other intruders into the body. One effect of inflammation is dilation of the blood vessels, and widening of the natural gaps in the blood vessels which lets more fluid (and the cells within them) into the tissues surrounding the blood vessels. This causes fluid to build up in all the tissues of the body---legs, arms, and faces swell, abdomens become more tense, and fluid gets into the tissues of the chest and lungs.
This is made worse by direct inflammation within the lungs; major surgeries are usually performed under general anesthetic (
http://wiki.medpedia.com/General_Anesthesia ), including putting a breathing tube into the airway and blowing gas into the lungs. Additionally, surgery patients generally receive a (relatively) large amount of IV fluids, which move into the extravascular spaces as well.
Finally, there are abnormalities which can make fluid move into the lungs even more. If the heart does not pump well enough, fluid can build up behind it and be pushed into the lungs. If there is actual infection in or trauma to the lungs themselves, this makes the inflammatory response even worse. Finally, any change in the concentration of blood (especially in the amount of proteins) can allow more fluid to leak out of vessels.