How do you start a game where you don't rail road the players?
I recently started a campaign I homebrewed, where the party starts off in prison ( their backstories merged together for the prisoner life), the party spends their way to the cells and every waking moment while in the cart casting some warlock spells to fuck with the guards, after a while they are finally tossed in their cell, i had a guard start off their introductions by noting down their information. I then had an NPC i made, help bring them out of prison if they swore to not harm the group he represented. The party swore and down into the sewers they went, one of the members walked into a cube, and fell unconscious because it took a while for the group to pull him out. There they had an encounter with a hydra, the party was too under leveled so the npc swagged down a potion and distracted them. the party ran outside, though they saw some gold on the way but they didn't want to pick it up, there was a small hallway where there was a ladder, to which they rode it out of the prison, revealing they were in a barren tundra, the party then got assaulted by wolves, 2 people went unconscious, and after a while the battle was over, and the party had won, the session ended there and there were a number of people complaining about the difficulty, then length ( it went on for 5 hours), and many said i railroaded hard.
How do i become a better DM?