Why can premature babies sometimes have trouble breathing?

Lungs not ready. Fetal lungs continue to mature until 39 weeks. Babies born prematurely have difficulty breathing because their lungs and muscles have not fully developed/matured and cannot process gas exchange efficiently. Prenatal Betamethasone shot to the mother can accelerate fetal lung maturity.
Finish work missing. The lungs have finish work that must be completed before air breathing is done easily. Like painting the rooms as you finish your house, the lung tissue must form a liquid coating that lines the inside of the air sacs & prevents them from emptying when you exhale.If a premi isn't making enough, it causes the breathing problem because air sacs many don't stay open & baby works extra hard to breathe.