One reason it was so hard for Germany to invade Russia/the Soviet Union in World War II (and I) was because the Russians had a different (wider) railroad gauge than that of most of the rest of Europe, making European rolling stock useless on Russian railways.
How did Germany resolve that problem in World War II? Did it capture enough Soviet rolling stock to use on Soviet railways? Did it build "trunk" lines in the Soviet Union to e.g. Stalingrad and other critical points on the European gauge? Or did it leave this problem mostly unresolved, thereby contributing to the German defeat?
The overall answer is that the Soviets were not rich in railways and destroyed much of it as they retreated. The Germans anticipated this, and had railway commandos rebuild much of the Soviet trunk lines and some feeders to standard gauge. They also maintained several of the wide gauge lines if captured intact and with enough rolling stock. Some efforts, primarily in 1942, were hindered either by the inability of the commandos to keep up with the front, or by the low capacity of a wide gauge line.
It was more of a nuisance, than a reason for defeat. The part of a track that is hard to build is the bed. To narrow a track, all you have to do is pull out the spikes, move the rail and drive the spikes back in again.
The bigger problem for the Germans was that the rail system in Russia is a hub-and-spokes design where all roads lead to Rome, meaning Moscow. The Germans didn't need rail lines going to Moscow. They needed rail lines going to Berlin. In other words, the big problem was not the gauge of the railroads, it was their direction.
The Germans changed the gauge from Russian to German and could then use their own equipment. "Die Eisenbahnpioniere" at lexikon-der-wehrmacht.de shows Wehrmacht military railroad engineers changing the gauge. Reichsbahn personnel, civilians and forced laborers were also used to change the gauge.
Actually, the problems were worse than just rebuilding the railroads to narrow the gauge. Soviet stations, where trains were refuelled were too far apart for German engines - the larger Soviet engines carried more fuel and water and could go farther.
The Germans had to rebuild the railroad to a narrower and also create new stations along the path to support their supply effort.
One problem was the substandard roadbed in Russian railways limited the weight of trains that passed over them - this included rail bridges and trestles. The Germans often had to substantially fortify roadbeds and trestles even before changing the rail gauge. Another problem has been referred to here - which is that German trains required more frequent stations for water and coal. Not all coal is the same. In Germany, over 90 percent of coal is low-energy lignite, so German locomotive design were dictated by this and had very large fireboxes to generate enough heat from lignite. Even when better grade Polish bitumen coal was available, the German locomotive design resulted in very inefficient usage of the better coal, meaning the German locomotives (the two main types were the 52 and the 42) needed refueling more often than Russian locomotives which were designed with smaller fireboxes because most Russian coal from the Donbas is bitumen.