While i agree many people can be pretty inmature, i would not say that only people in the military, poor, raised by single parents or abusive Households are the ones who grow up as people.
I think some of the reasons some people mature are these:
1-learning discipline (hopefully from an early age if Possible). Discipline helps with self control, which affect how people handle frustrations, and how capable they are to delay gratification for something better in the long-term. (While learning from an early age helps to make this easier, is never too late.)
2-putting things in perspective: to understand what things really matter in life and having a moral compass. Some people realize what matters after some adversity, but sometimes a good ethical education can help this proccess without the pain of adversity.
3-learning to think: yes, i know people take it for granted, but some people don't think about why they do some things. They end up like a leaf in a river not understanding how they reached certain point in their life without understanding the consequences of their actions.
4-a sense of purpose: when people know where they want to go in life, they perform better. Sometimes people do foolish things because deep down they feel lost and don't know what to do with their life. Sometimes they may fall in some vices to distract themselves for this feeling of despair.
Luckily, humans are creatures that can grow and change, so is never too late to become a better and more mature person, but is also important to point out that people only grow when they are willing to grow.