The intercostals muscles between your ribs plus the big diaphragm (the elastic floor of your ribcage) rhythmically change the size, shape and capacity of your chest. It is this squeeze-and-release that moves the air in and out of your ribcage.
To inhale, the intercostals lift and swing your ribs out and up (much like raising an umbrella). Simultaneously, the diaphragm flattens and descends slightly. This beautifully coordinated muscle-dance creates a slightly enlarged cage with increased capacity. Fresh oxygen-rich air rushes in to fill the new vacuum (similar to the action of a syringe or a bellows).
Once your lungs have processed the incoming air, exhalation is simply a matter of relaxing the intercostals and the diaphragm. The ribs drop down out of their upward flare while the diaphragm rises to return to its domed-up resting position. This overall letting go results in a slightly smaller ribcage with a smaller capacity. In this now-smaller cage, there is no place for the contained air to go, but out.
You can imagine that stress and tension would interfere with the free and full range of your breathing muscles and therefore the delivery of oxygen in and carbon dioxide out.
Be well. Breathe beautifully.