not exactly sure but I think it goes like this
assuming for railroads its 60 / iMovement (it might be 120 or something else, not sure)
If iMovement = 20 then the unit can move 3 tiles (60/20 = 3)
If iFlatMovement = 6 then the unit can move 10 tiles (60/6 = 10) on flat tiles I presume (i.e. not on hills)
From my testing. "Flat" has nothing to do with the terrain. It appears that two calculations are done. Let's use as an example a mounted unit with two MP per turn. You start by multiplying that 2 MP by 60 and get 120 total iMovement points the unit can expend in that turn. Divide that by 20 and you figure that the "2 MP" unit can move 6 tiles along a road during a turn, which is twice as fast as a "1 MP" unit can move (60/20 = 3). But that's only the first calculation....
You also have 60 iFlatMovement points ("Flat" in that it is not multplied by the nominal MP of the unit). Regardless of how many MP a unit has, it can move 10 tiles along a railroad during its turn. Since 10 is more than 3, 6, or 9, units with 1, 2, or 3 MP would use the Flat calculation, as it's better.
But what if we had a unit with 4 MP, that still obeys terrain and benefits from routes (unlike choppers)? Well, 4 MP * 60 = 240 iMovement, and dividing that back by 20 gives 12. In that case, the unit should be able to move faster than the "Flat" 10 tiles/turn from the quoted calculation. The idea is that a Railroad automatically includes a road as well, as if a RR had an invisible frontage road running parallel to it. Any unit that would be able to move faster on a road than the train could carry it on the RR would then use its own native (non-flat) movement on the (implied) road, and leave the RR's "flat" movement for units that are slower than trains.
I'm interested in finding out how to make this implied road a bit more explicit. I'm trying to find out if there's a place where you can specify that building a railroad on a tile is faster if that road has already been built; it wouldn't have to be built along with the RR so it should slightly speed up the process. As it is, I often build roads on hills before I have RR just to get the worker up there a turn quicker once RRs can actually be built. It would be nice if they got an additional bonus for having some of the work already done.