Explaining what characters would understand in context is not the same thing as railroading.
If the revelation of the lich is so stunning that residents of the starter area in general would be frightened enough to leave for the other continent, then that's something the characters themselves would know. If these characters would naturally have enough fear to consider leaving the continent, just make sure the players know what the characters already know.
Railroading is deciding and implementing a course of action for the characters without allowing players the agency to influence that. It's not railroading to tell the players information about what their characters would already know and present them a choice based on that information.
For example, you might tell them something like the following: "Most people are fleeing the continent to get away from the huge, serious, deadly threat of the lich. I think your characters would strongly consider fleeing for now as well. They would be aware that they are simply not strong enough yet to deal with this kind of threat and the resources they need wouldn't be found in an isolated area like this. You can try to struggle against the lich here, but if your characters are being rational they would know that's an uphill battle. The fear and need for better resources are pretty motivating. Do you want to stay and take the risk or do you want to leave for the continent with the other evacuees?"
Giving leading information to a question isn't railroading. Sometimes there is only one rational decision to make. As long as you leave them the option to choose to stay when you prompt them, you're not robbing the players of their agency. If they choose to stay then they must have some really brave or irrational characters, and they will face whatever the consequences would be (not that you have to manufacture punishment, just that things will be tough because that's what makes sense in context). If they choose to leave then it will probably be because they agreed it makes the most sense from a character perspective based on the information given.
As an analogy, telling the players "there is a thief on the loose and your neighbors are all locking their doors, you characters probably should too" does not mean the characters have to lock their doors... but they would be silly not to. The players can still decide for themselves, and you can come up with sensible events to follow up on either decision.
Group Checks, Success with a Cost, and Skill Challenges
These three concepts are meant to be used in tandem, but can be cherry picked to suit your style of play. I have the most experience using them together.
Group Checks
This is pretty simple. Half the group has to pass at doing some thing. In the examples you provided, this represents the party collectively crossing the rickety bridge, or a group effort to handle Materia.
Perhaps the Bare Minimum of 2 out of 4 people make the check/save.
"Wizardface nearly falls through a gap in the rickety bridge, but McFighterson manages to grab his wrist in time. The rest of the walk is slower as you take your time, but there are no other events of note."
You can secretly game this by knowing how likely it is for at least half the party to pass, based on the dc and their bonuses, and you don't have to worry about the wizard with the -1 acrobatics (or whatever).
If your group is bad at remembering inspiration, this is a good time, in my opinion, to remind them it exists.
Success with a Cost
"SwaC" is a hugely useful tool (okay, no one calls it that... yet). Maybe you want to leverage inspiration, mundane gear, spell slots, or hp.
Wizardface starts to slip through one of the tiles. McFighterson and La' Rouge are close enough to help, but they'd have to sacrifice the --insert thing here-- to get to him in time. Maybe it's not so bad at the bottom? What do you do.
This can be preemptively used, without rolling. I've had situations where I allow things to happen, wherein the party pays up front (usually at the party's suggestion).
Party: If we spend 2 inspiration, can we assume that the party makes it across?
DM: Of course. That sounds reasonable. Please describe your crossing and a hardship that you overcame
This allows them to enjoy the narrative feel where there is still a cost.
Skill Challenges
Disclaimer: I have adopted this from Matt Colville and his video on Skill Challenges.
This does not work for every scenario, but can be made to work for many. Choose a threshold, based on difficulty of the thing. Maybe it's 3 successes and 3 failures (adjust the number of successes for more difficult things). It may help you to think of this as a "race against time". In the case of the Materia example:
Barry Barbarian knocks over a box of the unstable element and one of the canisters begins to hiss and glow. You guys don't have long before it ignites and sets off the nearby canisters. The goal is three successes before three failures.
Then the group goes around, requesting to make proficient skill checks. The same skill cannot be used more than once, by the same character. Characters must be proficient in the skills. Players should be able to justify the skill in question. "No, unless you can explain how animal handling would help, you can't use it."
This might go something like the following:
Barry Barbarian succeeds at a survival check to retrace their steps.
McFighterson suggests using athletics to pry open a door that had warped from the reacting Materia. Success!
Rapier la' Rouge attempts to find a shortcut using investigation, but is unable. A vent of plasma bursts from the rivets of a nearby wall, causing light burns.
Wizardface is trained in Arcana and thinks he can predict a reactive fissure in the nearby steel-work. Success!
The Party escapes, managing to salvage one container of the materia. A more careful extraction would have made them a fortune, but the group feels fortunate to have kept their lives.
Honorable Mention: Make failure less fatal
Is there something about your cool scenario that could save the failing character? Perhaps the ravine is sloped and leads off into some unseen area? Perhaps the highly reactive Materia irradiates (bestows a curse) onto the nearby characters? Maybe the collapsing building only does 6d6 damage instead of instant death?
This isn't always going to fit the tone you want, but often, you can find that the unknown is just as terrifying as the certainty of death.
Best Answer
Telegraph the problem in advance
It sounds like the real danger here is that the group might communicate sincerely with the spymaster, and this could lead to the spymaster killing them all. You can avoid this by letting the group discover evidence that the spymaster is treacherous -- perhaps people they talk to can complain that the spymaster is using trumped-up charges and doesn't seem to care about anyone's actual guilt or innocence.
Alternatively, you could have the group's door kicked down by a collection of guards sent to arrest the PCs. The group wins the battle and then they have to decide what to do next. This might lead to them going back to your original plan of getting out of town quickly.
Remember that NPCs often don't have a good estimate of the PCs' combat ability, and (especially for the first fight) they might not send enough guards to be a real threat.
Scale down the levels
Many of your problems are caused by your decision that the NPCs involved in this fight are super-high-level. You can just decide otherwise. Maybe those six heroes of long ago have gotten rusty since they stopped adventuring. Maybe the spymaster is now a CR8 assassin (from the monster manual). (Or you could build the spymaster as your own boss battle.)
Let them do a jailbreak
If the group decides they want to do a jailbreak, you should let them do a jailbreak. The spymaster probably isn't personally guarding the jail, so the group can have battles against reasonable NPC opponents.
You can encourage the group to do a jailbreak by letting them find out what jail is holding their friend. They're probably researching that anyway.
(source: I've been the DM for multiple runs of a campaign where the group is battling against the leadership of a small town, and I played in the start of the Hell's Rebels campaign where the group has to organize a jailbreak.)