@Porcupineintherough there are probably a few reasons for that, from the situation in the country they’re leaving to individual circumstances.
If you’re leaving a country at the beginning of a war/instability, you’ll likely be relatively well off from having had a stable job, will likely have a passport and therefore be able to afford to fly to another continent, and airports will still be functioning. You can then claim asylum on arrival.
From personal experience, people of my parent’s generation who left the Middle East were relatively well off, (although I’m sure here were also many others who weren’t) but being persecuted by the regime for promoting democracy or being critical of the government. They were imprisoned, threatened with torture, family members were imprisoned and questioned. They were able to fly out and claim asylum in the UK as their lives were in danger in their country. They were able to leave as the country hadn’t yet descended into civil war or worse instability.
If you compare that to the current situation in Afghanistan for eg, there’s massive instability, people may not have access to passport/visas, there may be no functioning embassy to help people leave. If you can find a functioning airport, there may be scrutiny/ID checks, so if you’re in a persecuted group you’re putting yourself at risk by trying to leave.
3/4s of households in Afghanistan can’t meet their essential needs so there’s no money to spend on flights and visas even if flights were available.
This is also eye-opening - even though the government promised a “warm welcome” to refugees from Afghanistan, most have no way to apply for asylum from Afghanistan. One of the government’s resettlement schemes has taken TWO people since April. 1 in 4 of those crossing the channel in small boats are from Afghanistan and include people who supported the British army, who’ve been left with no other way to reach the UK.