The condom is used to protect the barrel of the gun to prevent it from rusting. Not the whole gun. If you do a search on the net, you can actually find that it's an inexpensive yet effective way to protect the barrel.
It can also be used to protect the barrels from sandy environment.
Some sites for reading...
http://aidssupport.aarogya.com/index.php?option=com_content&task=view&id=44&Itemid=59
"In WWII , the Vietnam War , the Gulf War , and most recently in Iraq the U.S. military instructed its soldiers to place a non–lubricated condom around the muzzle of the rifle barrel in order to prevent moisture, sand, rain, etc. from fouling the weapon without hindering a bullet in case of firing."
http://en.wikipedia.org/wiki/Condom
"Condoms excel as multipurpose containers because they are waterproof, elastic, durable, and will not arouse suspicion if found. Ongoing military utilization begun during World War II includes:
* Tying a non-lubricated condom over the muzzle of the rifle barrel in order to prevent barrel fouling by keeping out detritus."