Mechanical ventilation helps inflate and deflate the lungs.
There are a variety of ventilation systems that use a system to push gas/air through a tube to the patient's airway.
Other systems rhythmically change the pressure around a patient's chest. When the pressure is low, air flows into the lungs; when it increases, air flows out. These are called negative pressure ventilators (e.g., iron lung, chest cuirass), and were commonly used during the polio epidemic in the 1950s.