Using stainless steel is unlikely to be the solution chosen
It's probably possible that you could envision a world where the engineering trade-offs made it reasonable to use stainless steel. However, that would likely require significantly tweaking the economics of the entire lifetime of the track, the atmospheric conditions to make corrosion substantially more of an issue than it is in our world, and some of the properties of stainless steel in order to make it more attractive for this use.
These would need to be fairly significant changes among all aspects of the lifetime of the rails. As has been discussed in other answers, using stainless steel for this application has serious negatives in our world. The changes would need to make the economics of using stainless steel sufficiently favorable in order to overcome all of those negatives. In addition, the changes would need to make alternate solutions to corrosion control not economically feasible.
Use other methods of corrosion control (e.g., cathodic protection)
An important aspect that hasn't been discussed in other answers is that there are other, more effective, methods of controlling corrosion, or even just designing for accepting more corrosion, which are already in use in the real world in environments where corrosion is more of an issue. In our world, such environments are typically where water, especially salt water, is present in significant quantities. Some examples of those environments include boats/ships, water heaters, underground structures, in-water structures, etc.
In such situations, the typical choice, in addition to other mitigations (e.g., painting or other coatings, which, obviously, aren't options for railway track, due to the nature of their use), is to use a form of cathodic protection, which is either impressed current cathodic protection (ICCP), where a voltage is constantly applied to prevent corrosion of the material being protected, or using a sacrificial anode, more properly called a galvanic anode to have the corrosion occur in another metal object that's electrically connected to the rails. Such sacrificial anodes can be made to be substantially easier monitor for excess corrosion and easier and less expensive to replace when needed.