In the early 30's Stalin said something to the extent that 'if we don't match Germany industrially, they will eventually crush us." He instituted Five-Year plans to expand heavy industry, required a lot of sacrifice on the part of the Soviet people. Some of the work was done by GULAG prisoners. Agriculture was also collectivized, at that time, causing man-made famines in the Ukraine. There were also internal political aspects to collectivization.
When war came in 1941 the Soviets shipped many of these factories to the east, away from the Germans, and they started producing again. The equipment, munitions, etc., were vital in stopping the Germans and pushing them back, in addition to heavy foreign material assistance.
In the end, Stalin's USSR won, but at a terrible cost.
This is in a nutshell. I invite all and sundry to do a search, get more details.