1. A pneumothorax is a collapsed lung.
2. To answer this question you need some rudimentary anatomy. The lungs sit within the chest cavity. Surrounding the lungs is a lining called the plueral lining. This lining allows slippage during normal respiration so that the lungs don't stick to the inside of the chest wall. There is a potential space between this lining and the chest wall (it's there but hard to tell due to the closeness of the organs). Anyone can get a pneumothorax by getting blood or air or other fluids stuck between the lung and chest wall in that potential space. This causes positive pressure in a space that is normally negatively pressurized. This positive pressure pushes on the lung causing it to collapse.
3. To avoid it as a diver, one just continuously breathes, always exhaling when the regulator is in or out of the mouth. This allows the expanding air to escape rather than causing the excess to be forced into the potential space and causing a pneumothorax.
4. The treatment for a pneumothorax, depending on what caused it, is to negatively pressurize that space again. The only true way to do that is to stick in a chest tube, which allows the fluid or air to drain out and results in the lung expanding again. However, if the chest tube can not be placed in time, surgery will need to be done to re-establish the lung volume as the lung will begin to stick unto itself. This is not something divers are trained to due, generally speaking, unless they have advanced medical training (ie emergency medicine physician, paramedic, etc).
Any other thoughts from the medical community?