To understand why this happened, just think about the fact that WWII was the most mechanized war in history up to that point. Think about all the airplanes used in that war -- the first war where airplanes were extremely important. Think of all the ships that were needed to carry supplies from the US to Europe as well as all the way across the Pacific Ocean, eventually almost all the way to Japan.
Then think about all the bombs and the guns and the bullets and the uniforms and the food. All of that stuff had to be made by someone and those someones had to do the work in factories.
So the answer to this is that so many people went to work in factories because so many manufactured goods were needed to fight this war.