You are describing a rather awkward scenario. Sharing a device like this is obviously not an intended scenario for the automatic switching. Sounds like you should just go into all your devices and disable automatic switching. You can do this on iOS, iPadOS, macOS and tvOS. If you just disable automatic switching on all your devices your issues would no longer be present.
It's quite obvious for your phone to switch from AirPods Pro to the AirPods Max when you have automatic switching on. As the AirPods Max was connecting after the AirPods Pro there is no real sensible reason for your phone to expect it should be still using the AirPods Pro. Why would you pick up your AirPods Max if you weren't going to use them? This isn't really illogical at all. The only reason this becomes illogical is because you share the AirPods Max with your wife, making it into a scenario where you on your device suddenly have two different AirPod devices that suddenly can be active both at the same time, which obviously makes things more confusing. If it wasn't for the fact that your wife is trying to use the AirPods Max, while you are using the AirPods Pro at the same time, having both linked to the same device and Apple-ID this would be the most logical behaviour. When sharing devices like this it sounds like you should just disable automatic switching on all devices and pair manually.
But I do agree, automatic switching, especially between iOS/iPadOS and macOS tends to be spotty. But I rarely want it to automatically switch to my Mac so I simply disabled automatic switching to my Mac.