If you start building rails within range of your character, you can continue building them forever. There is no maximum "reach range".
https://imgur.com/fLAsuSl
If you do not start building them within reach, then you will get the error that you cannot reach as expected.
https://imgur.com/DIHpBfd
[0.17.3] Unlimited build reach on railroads
Re: [0.17.3] Unlimited build reach on railroads
It's been this way since the new ways of building rails were implemented way back when.