I looked into this year's ago because I was going to visit someone in Moscow and hate flying.
I remember reading that when you pass through the areas with different train gauges their is some sort of automated process for switching the train wheels.
Years and years ago though so I can't remember the details.