In animals, the lungs are the area where gas exchange takes place. Without gas exchange, oxygen would not pass into the blood from the lungs so the body cells would not be able to receive the oxygen needed for respiration.
The alveoli are moist to allow oxygen to move from the lung through the alveoli into blood vessels and red blood cells. Carbon dioxide passes from the blood into the alveoli. The oxygen-filled blood goes back to the heart and the carbon dioxide in the alveoli is pushed out of the lungs and into the air we breathe out.
Birds lungs do not have alveoli, instead they have millions of para-bronchi. These para-bronchi end up in tiny capillaries or very small blood vessels and they pass close to the body's blood vessels, so diffusion can occur and the oxygen and carbon dioxide is exchanged. The oxygen and carbon dioxide in birds lungs are continuously diffused into and out of the blood, not like in mammals where diffusion can only happen in the alveoli.
Reptile lungs open and close because of the ribs surrounding them pressing down on them and then opening up with the help of muscles. The liver is also attached to the bottom of the lungs and when a muscle which is attached to the liver pulls, the liver moves away from the lungs and pulls them, making them bigger.
Frog lungs are very simple compared to most other lungs, they are simply balloons, with moist outsides allowing for diffusion. But frogs do not move around much and so do not need lots of oxygen, but they can also take in oxygen through their moist outer skin if a big demand of oxygen is needed (e.g. Fight or Flight).
The axolotl (Ambystoma mexicanum) retains its larval form with gills into adulthood
Lung Facts for Kids. Kiddle Encyclopedia.