If both phones are within range it's mostly down to luck / who was the last driver.
If you want to maximise chances driver needs pull the handle first while the other one stays a couple steps behind.
Or you need to act fast to switch profiles on the screen if it got it wrong and you don't want your knees getting crushed (assuming like most of us your wife is the shorter one...)
This pretty much describes the situation. Wife and I have gotten used to having the passenger (whomever that is) not touch the passenger car door until the person driving opens the drivers door. Sometimes, the car still gets it wrong (we have both a model 3 and Y, and the 3 is my primary vehicle, the Y is hers).
If we are going somewhere together, and I am driving, I make sure to open the drivers door first. In general, what we do to make this "somewhat" organic, is whomever is driving is the one who goes in the garage first, the other person sets our home alarm system to "away" mode using its touch panel, then goes to the garage.
Setting the alarm gives a 5-10 second lag time for whomever went out to the garage first to get to the drivers door of whichever car we are taking, and open the door.
Even with that, sometimes the car is wrong. Not often, but sometimes. If i am the one driving, I have gotten used to opening the door and pausing a beat before I try to get in. If we are in the 3 (which remember I normally drive) if I open the door and the chair starts scrunching up, I know it selected her profile. When we are in the Y (which is her primary car) if I open the door and it DOESNT start moving, then I know its on her profile.
Its all become second nature at this point, and its one of those "first world problem among first world problem" things, but it did take some getting used to and also some tolerance.