The question I received was "How is
Step 1: Discuss the Campaign before hand.
This is a step that has honestly shocked me with how uncommon it is to see in groups. A lot of times it seems like the following conversation happens.
"Hey, lets have a campaign."
"Yeah, I can run. We'll play D&D"
"Awesome, so Thursdays at 6?"
and then the game starts. A few sessions in you find that one player has made a thief that is based around role play and charming its way through problems, one player has made a fighter built specifically for dungeon crawl, another is looking through the psionics rules, and so on and so on. Everyone has a different idea of what the game is going to be like, and the only person who knows is the GM. So if he is planning a more dungeon crawl experience, the players planning for more puzzle or RP based play are going to be disappointed and feel like they're being crammed into the game. Numerous cases of "railroading" happen because the game the players thought they were going to play, is not the game that the GM is running. So, as the players try to play a different game, they run into boundaries and bumpers that force them into the game that is actually being run.
The solution to this is to simply talk out the game before. Don't just say you want to play D&D or L5R, say what kind of game you want to play. "I want to run a D&D campaign that focuses on exploring a wizard's tower in a world that has become very low magic", it is just one sentence but your players now have a much better picture of what is in store for the game. The world is low magic, so a mage PC is not something the GM necessarily wants to deal with, at least not at higher levels. You're exploring a tower for the game, so it is probably a dungeon crawl. That is a lot clearer than just "I want to run D&D".
Even still though, telling is not enough. Ask your players what kind of game they want to run, while saying what you are willing to/capable of running. If your players want a Pulp Noir gritty 40's private eye story, and you have no ability nor desire to run that, then it is right out. On the same token, if you want to run a Post Apocalyptic game like the Fallout series, and none of your players do, that should also be right out. Come to an agreement on the kind of game you want. For the game that inspired this post, all the players were fine with, and wanted to play in a military game. So that direction you get from being in a military game was agreed on before hand.
Don't be Married to Your Story
The second leading cause of railroading that I have experienced personally happens when a GM gets married to their story. See, they've had the idea of the campaign in their heads for a long time, and over that time they've revisited it constantly. Tweaking NPCs, tweaking the role the PCs will take, tweaking how things will play out. Eventually the story starts to lock into place, it has formed into an idealized campaign. It is not "the PCs are five heroes having to go against the evil wizard Ragamar", it becomes a lot more like a book. Classes are thought of, events for specific characters come into play, love interests, betrayal, death, injury, all come into connection in the GMs head.
The game has, in essence, turned from being a game to being a story. So what happens next? after 2 or more years of thinking and planning this story out for an epic game, the GM finally gets a group of players to play in it. Only the players have ideas of their own. The Lawful Good Paladin isn't a male Paladin of Tyr, it is a female paladin of Amaterasu. The thief isn't a hard on his luck person just trying to survive, he is the wealthy son of a noble just looking for kicks. This goes on down the line for all the PCs. Sure the classes you need might be there, but the classes you generally need for a fantasy story are about the same. 1-2 fighters, 1-2 "rogue" like characters, a magic caster, and a healer. Most groups will fill this out on their own knowing they will probably need those roles. However, how those characters have formed is completely different, and we haven't even hit story yet.
The next thing the GM knows the players want to go left where he wants them to go right. They are unwilling to sacrifice where the GM wants heroic sacrifice. They pursue where they should stop. They're breaking the image of the perfect campaign, this idea that the GM has essentially become married to. So he forces things through. It doesn't matter how well they roll, or how quickly they think. That bad guy gets away, that treasure gets stolen, that fight has to be lost. All so that this perfect story can come out.
Do NOT do this! If you get to the point where your players going off track is bothering you, you need to step back and re-evaluate what is going on. Maybe you should write this out as a book, not run it as a game. Maybe you should just shake yourself off and realize that the only thing you can count on a PC to do is defy expectations at times, and that forcing them down a certain way isn't conducive to fun gaming. Either way, you need to step back and re-evaluate the situation.
The game in question, doesn't have a huge over-arching metaplot, in fact its story falls squarely and completely into step 3, so no worries here either.
Step 3: Keep the Focus on the Player Characters
This is one that is more a symptom of a railroad game, but it is advice to keep in mind to avoid it. Where is the focus of your story? If it is not squarely on the players, the game may be a railroad. Keeping the story focused on the PCs means that their decisions matter, they drive the story. It keeps them from being "just along for the ride", which is a bad feeling to have in a game. I've said this before, but in a normal Table Top RPG there are 5-7 people controlling the world. The GM and 4-6 players. This means that (assuming a 4 player game for ease of math) 80% of the creative force behind the whole world is on 4 specific people. If those people aren't special, I don't know what is.
For an example of what I'm talking about lets look at two movies. On the side of "not focused on the PCs" we look at The Thirteenth Warrior, for "focused on the PCs" we'll look at Star Wars (get used to it, I like Star Wars :D )
In the Thirteen Warrior, the story focuses on Buliwyf as seen from the perspective of Ahmed ibn Fahdlan. By this I mean that while the narrative focus is on Ahmed, our story teller (a PC for this) the actual focus of the plot is on Buliwyf, an NPC. Now you can argue that Buliwyf is a PC I suppose, but it doesn't show that much. He actually isn't on screen all that much, aside from at the plot important points where he takes charge. Now no matter what Ahmed does, Buliwyf's story is going to continue and be the focus of the story. Ahmed is just along for the ride, watching and reporting on just how awesome and bad ass Buliwyf is.
It makes for an entertaining movie and story sure, but not a particularly fun game where all the important stuff is done by someone the PCs get to watch. Their adventure basically boils down to "Yeah, I knew Buliwyf the great, he was a great man. I was there for some of his major victories, I did my best though I'm not sure I actually did help any...". Do you want to play in a game like that? I don't. I like having an impact in the games I play in, and helping to tell the story not just watch it.
Compare this to Star Wars however. In Star Wars the story focuses on 4 characters, Han, Luke, Leia, and Chewbacca. Now Chewbacca may or may not be a 'PC' but he is around enough that you can fairly easily consider him a new player, perhaps Han's younger brother who is new to gaming. Now there is an over-arcing plot going on of the Rebellion facing the Empire, but a PC is at the heart of each and every one of these moments. The Rebels lose if Luke and Han don't destroy the Death Star in A New Hope. Darth Vader is personally pursuing Han, Leia, and Chewbacca in Empire Strikes Back while setting a trap for Luke. Return of the Jedi has Han, Leia, and Chewbacca playing a key part in the destruction of the second Death Star while Luke wraps up his personal plot with Darth Vader.
The story doesn't really take its focus off of those 4 people, and when it does it isn't for long. It essentially works as a quicker way to get some information across rather than watching "sessions" worth of game time where the PCs find this stuff out. If at any point in time Han, Leia, Luke, or Chewie decide to back out, the story would change dramatically, if not end in complete failure.
That is what you want to have in your game. You may or may not have a meta-arc, but it focuses on the PCs. They are the main characters. Other NPCs can be big, important, and capable, but the PCs should be the ones who matter most. They make decisions that cause ripples, ripples that effect other things and change the world around them. If they go left, the story goes left. If they die, the story stops (or at least that part of it). The universe may not, but the story does revolve around them.
Wrapping things up, this is exactly what the game that inspired this post has in spades. The story is completely focused on the players. In fact, the closest thing to a story the game has is a focus on the PCs unit and the people inside it. Watching as they grow up and develop into insanely competent soldiers. The game follows the PCs, the PCs shape and change the world with their actions, their victories and failures carry echoes to other aspects.
Combining these three steps helps give a very fun game that people will talk about for a while. Having everyone on the same page starting off, means that the characters that come into the game are characters that will fit into that kind of game. Not being married to your story means you have one, only it is able to be modified by the actions of the PCs. The same is true with keeping the focus on the PCs. Make them key instruments in the story, give them their little specific plots that weave together to make the big story.
Engage your players, involve them in the world, and they'll respond. By keeping this focus on the players, the world will in turn respond to them, and you don't need to worry about railroads.