I would reckon that for the rules to prevent railroading - that is, for it to be
against the rules, then there must be appropriate
game structures within the rules that mitigate against railroading. (I say mitigate against, since a DM who is determined to railroad will surely do so, regardless of what the rules say.)
For instance, random procedural generation makes it harder to railroad since, if you hew to such a process reasonably closely, all you're doing is creating content (often fairly quickly and efficiently) that is there for the PCs to interact with or not as is their wont, or at the very least is orthogonal to the decisions they are making, depending on the kind of content being created. A site of interest, for instance, is "passively" there, and the PCs can choose to explore it or not. Weather and random encounters are, you might say, "actively" present, but are often orthogonal with respect to meaningful choices the players might make. Once a PC can cast
control weather, they can make meaningful decisions about the weather (but how often will they want to?), and the PCs might be able to make meaningful decisions about the quantity or nature of random encounters they might face without necessarily being able to completely eliminate the risk of doing so, but usually the fact that a random encounter happens has no bearing on the PCs' decisions - it's just a risk of venturing out into a dangerous world.
Strictly speaking, some background features are also
rules that also mitigate against railroading. But they're also sporadic and unsystematic.
Of course, the DM rules for 5e generally don't include robust game structures for a variety of situations, although the DMG does include many a random table for content generation, because the design intent, as best I can make it out, is to avoid tying the DM's hands in this way.
BUT ignoring the rules is another key way to railroad - the above-mentioned "the fight ends when I feel like it" could be a kind of railroading if the players ever find out (and they will) because it renders their choices meaningless. If this annoys the players, you have railroaded. Sticking to the rules is one way to keep yourself from railroading. It doesn't prevent railroading entirely.
Interestingly, IIRC AngryGM wrote an essay about combat, which more or less agreed with the Tweet cited upthread, except that he framed it in terms of meaningful choices. Basically, once the players were
out of meaningful choices in a combat - once it was all over but the mop-up - it was time to just narrate an end to the combat. On that view, once the players have run out of meaningful choices to make in a combat - which you hopefully discern by, say, them getting bored - then if anything, respecting player agency means narrating a swift end so that they can get back to content that does engage them (and provide new meaningful choices to make).
This view is agnostic to the duration of any given combat, nor does it require that all combats must eventually end this way. Note that like Daniel Kwan's Tweet, it
does not make any claim to the effect that "the fight ends when I feel like it". Indeed, Kwan's Tweet shows his incorporation of this idea outlined by Angry (or some version of it) into his decision-making, along with two special cases, both of which encourage player engagement with the fiction (by coming up with "super awesome" things to do and by establishing in-fiction relationships with NPCs), which is more likely to result in in empowering player agency than restricting it.
(It must be said that, to the best of my recollection, Angry's essay applied to 4e combat, but could very well apply to any edition of D&D combat.)