First part is a result of industrialization.
Partially, the other huge part is that the products of production were funneled into safety nets and state projects like railways and universities, providing free education and healthcare, and not corporate profits.
I genuinely think the idea of communism is great, but human nature will ensure that it will never be successful. There will always be someone who gets greedy and takes more for themselves in the pursuit of wealth and power.
What’s considered “Human Nature” changes alongside Mode of Production. It isn’t Human Nature to be greedy, greed is more often expressed within Capitalism.
Additionally, wealth disparity went way down in the USSR. It wasn’t a case where some few individuals profited massively and others lived in squalor, wealth disparity skyrocketed after it collapsed.
Are you familiar with Marxist Theory? You have a decidedly Idealist take, rather than Materialist.