My wife has an iPad, iPhone, Apple watch, and iPods.
I have just iPods.
There are countless times when I'm listening to the iPad with my iPods, and when she comes into range, either my iPods switch connection to her iPhone, or her iPods steal my connection to the iPad.
I've found no setting on any device that fixes this. It drives me insane.
I think this is supposed to cover your use case, though given the general Bluetooth unreliability, I won't be surprised if it didn't work as expected.
Bluetooth isn’t perfect in Apple world (multi device handoff doesn’t always work for me) but it’s substantially better than the chaos described above.
I’ve never had a situation where my AirPods started cutting out depending on how I walk (like the OP described) for example. I can walk several rooms away from my device before they start cutting out.
Having done some Bluetooth work before, the quality of everything from the stack to the hardware to firmware varies greatly from device to device. Anything Android was a nightmare a few years ago but it was getting better.
Budget Sony headphones I bought last year work great with my iPhone. No complaints at all.
The Bluetooth stack on my iMac has a bug where it will crash hard after around two weeks of uptime. Very annoying, because the (Magic) Keyboard and (Magic) Mouse stop working. Only way to fix it is a restart.
These days I have Sony earbuds and they stay connected only to my iPhone.