Most commonly they were simply routed around.
OK, maybe I made that sound more simple than it was. When every route is covered by 'bandits' of one stripe or another, 'just route around' is easier said than done... but, what happened is that the bandits started competing.
There were two routes that could be taken to market, each harbored a different gang. One year, gang A simply took everything that tried to pass. Big gains for them that year. The same year, gang B was a little more restrained, and only 'taxed' caravans but let them go on through after coughing up a fee. Their gains were smaller that year, but the next year, caravans came through their territory and contributd to their coffers again. Gang A's territory received no merchants. Gang A got no gain from this, and would see no gains from it again for a decade or more, until they were finally driven out by a new gang which behaved differently. Gang B, on the other hand, gained more than the first year, as they now had all the traffic rather than half of it passing through their territory.
And thus was born taxation. Eco-friendly theft, sustainable banditry. The first guy to try it was no doubt considered an imbecile by his peers, at first, but it soon proved to be an advantage that only increases over time and the taxers not only held on but soon enough put the old-school bandits at a permanent disadvantage that continues to this day.
And so over time the taxer chiefs became Barons, and the Baronies were organized into Kingdoms, and the Kingdoms into Empires, and the the Empires fell apart into Baronies and Kingdoms again, a cycle that in some older areas has probably repeated a dozen times, and then after much time all of these groups were swept away by the new secular religion of nationalism, and Nations were invented to replace them. But the scam remains essentially the same regardless of the time and place.
How would that translate today? Well if we could get a clear corridor through the country of jurisdictions that repudiated this and other forms of robbery clearly, a lot of travellers would be willing to detour significantly in order to remain within that corridor. The jurisdictions that continued the robbery would, like gang A, effectively be cut out of the game, and even though travellers would make it through with most of their belongings each one would certainly drop a few dollars in taxes on these jurisdictions as they passed through. But getting the ball rolling, getting the initial free corridor on line, I got nothing practical on that at the moment, I am sorry.
It probably was not easy to do that the first time around either though. We may have existed as a species for a couple of hundred thousand years before we actually progressed to the point where travelling more than a few miles did not involve a likelihood of mortal combat to begin with.