IIRC Russian army had, prior to the outbreak of the current war, several tens of thousands of soldiers specialized just in emergency railway construction and repairs. IDK how many remain now.
Russians aren't stupid, they know that the enemy will try to destroy the tracks when retreating, so they train to fix/bypass the problems quickly.
That includes some transportable improvised bridges ready for deployment.