Some of it will come down to the writing and some GM execution. Not all adventure paths avoid tendencies to railroad and a GM cleaving too close to the script might lean railroad to save it. Though they are not inherently railroads ime.
Right. I have an example that shows why the DM simply having a specific end goal in mind isn't a railroad.
Decades ago a buddy and I had only LARPED Vampire the Masquerade. We hadn't played the sit down version. One of the three Los Angeles game conventions arrived and we decided to enter the pencil and paper Vampire tournament to experience that version of the game.
The premise was that the prince of the city had been killed and we the primogen had to track down and kill the assassin. Whoever of us contributed the most to the goal would become the new prince. They ran the first half of the adventure like 6 or 8 times on Friday and Saturday, and the two groups who did the best at the first half, would play on Sunday and the best group would win the tournament prize.
So this was a linear adventure. Let's say they went from A-Z in their adventure, with Z being the showdown with the big bad at his compound after breaking through his defenses. Day 1 would be A-M, and Day 2 N-Z.
We figured out who did it very early on. This game was set in Las Vegas and the guy who killed the prince owned a casino. We got to the casino just in time to see him walk out of the casino towards a heavily armored limousine. My character was the Tremere primogen and I had maxed out fire magic. The highest level said that I could create fire like a bonfire, so I wasn't sure if that meant strength, size or both. I had the idea to use fire magic to burn the guy alive as he walked to the limo, but I didn't do it because of my uncertainty.
We went through the end of the first session and were in the process of figuring out how to break into the big bad's compound when the session ended. We were told that we got farther than any other group, so we were in the final two for sure.
At that point I asked one of the DM's(there were 3 or 4 handling the two groups playing that night, all in the same large room) if the fire magic could have been condensed into a small area to immolate the guy as he was walking to the limo. He blanched a bit and was like, yeah, you could have. He then said that would have been a breach of the masquerade. My reply to him was that no vampire was seen, and spontaneous combustion was well documented and many people believed in it. I also let him know that my character controlled the city's entire media and I would have had all the stations and papers printing articles about how he spontaneously combusted.
That was when he ran over to the other DMs and they had a huddle. When he got back he was like, "Yeah, that would have worked. The adventure would have been over and a success right then and there."
Despite having the clear end goal of fight the big bad in his lair, I could have ended the game at step D or E and not Z. THAT'S why linear isn't a railroad. My agency was there and I could have completely negated their set up end goal. They could have come back and told me that it should have worked, but they would have stopped it from happening because the other groups who were vying for the prize wouldn't be able to win, in which case that would be DM force stopping me from acting as I should be able to. Then and only then would it become a railroad.
Linear is never inherently a railroad. DM force must be added to it for any kind of railroad to happen. Absent that force, the group could achieve the victory early, find a completely different route to victory, or just say screw it and leave. If they don't have to go to the DM's end goal, no railroad is present.