(Highway police (https://en.wikipedia.org/wiki/Highway_patrol) can have the same role for roads(
Some countries also have special electricity networks for rail, “generally […] only if the railway in question uses alternating current (AC) with a frequency lower than that of the national grid” (https://en.wikipedia.org/wiki/Traction_power_network)
Other large enterprises in the USSR had similar things, to one extent or another. Railway police are common in other countries.
I think that capitalism was kind of hi-jacked by the money guys at that point. Lots of company towns where, if not thriving, getting along, working. Not super profitable but doing ok. Then practically overnight they turned to wasteland when the mills closed.
For other oddities, USSR has army, navy, air force and anti-aircraft branches.
In the Soviet Union, and to a great extent in Russia till now, railway system is very independent from the State. It's frequently called a state within a state. It has it's own power stations, construction departments that build among other things, housing for workers, their own hospitals and even their own medical schools, it's own police, their own hotels and Black Sea resorts for workers, in the Soviet times they had even their own Gulags. It's a closed-loop system largely independent from the rest of it. So they have their own take on schooling, too.
Happened that way because after the Revolution of 1917, the state largely collapsed and was unable to do shit for at least next 6-7 years. Railway had to figure out how to work on its own.