There's two big reasons I know of for why people go off against linear games.
1: A linear game is the hallmark of either a new DM, or an experienced DM who is/thinks they are dealing with inexperienced player(s). Linear adventures require about the same ammount of prep-work as sandboxes, but less at-the-table creativity.
If your players want to join the orcs and raid he elven village instead of what you had planned, an experienced DM dealing with experienced players could pull this off without breaking immersion or having the table devolve into a game of Murderhobo: The Derailing. It's easier for a new DM or an experienced DM dealing with new players to say "Look, that's not happening." and roll with the established adventure. Because of this, Railroading DMs get a reputation as inexperienced DMs.

2: Player agency is rare. Getting the ability to go off and affect the game-world is hard to pull off. If you're doing things in the World of Darkness or in Faerun, there's established niches for player parties, but the seats at the big-people table are taken. Different games and settings have this to different degrees, but it's fairly common for the design of the game to assume the players will go on their adventure, do their thing, and not be interested in becomming a trade mogul of the Western Continent.
So most DMs are blindsided when the players DO. Poor or inexperienced DMs react poorly to this, blaming the player for things like "Wrecking the game" or "Hogging the spotlight".
The thing is, player agency requires three things to pull off at a table: Inspiration, Research, and a game element the player feels they can or should be able to influence.

You don't get a player going off the rails if they feel satisfied with their character and the world around them.
Some players, it is true, get frustrated and shout things like "I attack the king!" while getting the reward, but other, more amture players will feel something is lacking, look into what the game system can offer them, and then roleplay out the plan for changing the world just a little bit. It makes the player feel like they have freedom, and increases the immersion factor of the game.

Here on the giant boards, most players don't get a lot of opportunity to play out that freedom, despite being well-versed in the rules and generally mature individuals. So the restrictions of yet aother railroad campaign chafe.

So that's why railroading gets flack.