A little background first: it turns out that Germany and the SU had different railway gauges (spacing between the insides of the two metal parallel tracks/bars?).
Considering the fact that it presented yet another infrastructural problem to the German Reich, and the fact that this info would likely be well known, how did they work around the problem?
They did, indeed. They did it the old-fashioned way. They re-gauged them.
Well, not necessarily all of them, they did prioritise which ones to re-gauge, and some lines they kept original and used captured motive power and rolling stock, but the goal was to re-gauge. It's not as complicated as it sounds, as the difficult bit is creating the railway bed. To a large extent, since the Russians would occasionally destroy the rail lines as they retreated anyway, they had to rebuild to begin with. On the other hand, when the Germans captured the recently 'sovietised' baltic states, the Soviets hadn't yet had time to convert the lines to their standard, which made life easier for the Germans.
It wasn't just the tracks which needed to be relaid, as Soviet locomotives, used to longer distances between anywhere of interest in that vast country, tended to have longer range between coaling and watering stops. As a result, the germans also had to build a supporting infrastructure for their locomotives.
I really can't do much better than to point you to this website which seems to have a reasonably exhaustive assessment of German rail operations in the East.. https://www.feldgrau.com/WW2-German-State-Railway-Deutsche-Reichsbahn