hi you can turn off the automatic switching in your AirPods to prevent to disconnect from one device to another because they detects audio and seamlessly they connect when one of your devices plays audio , let’s say your listening some music in your iPhone with the AirPods in your ears but you are working on your Mac and the iPhone could be in other room or not to close from u so if you play something with audio in your Mac the AirPods will detect that sound then they will disconnect from the iPhone to connect to your Mac , I had that experience before isn’t AirPods issues is something that you can handle manually in settings on your iPhone with the AirPods in your ears go to Bluetooth find the AirPods good luck to the blue circle then find, connect to this iPhone , get there and select the other option not the automatic as by default they are set it up