I would argue that Harry isn't actually defeated. Wand lore is a tricky subject, and the Elder Wand is very unique. It's hard to know what the wand is "thinking," but we do know that the "thoughts" are there, that's how the wand recognizes its master, decides to switch allegiance or not, and knows when it has found its original mate.
We also know that some of the most powerful magic is not performed by spells or potions, but by actions, particularly actions of love. There are examples of this in the books. Most notably is Lily's sacrifice to save Harry, but other things like Tonks' Animagus form changing to reflect her feelings for Lupin as well. I even have a feeling that Molly Weasley might not have been able to defeat Bellatrix in a standard one-on-one duel, but in the moment of protection for Ginny, her magical strength increases significantly.
My point with all of this is that Harry sacrifices himself to protect his friends. While on a very basic level, Voldemort "defeats" him, Harry doesn't put up a fight. He gives himself up in light of the larger goal of protecting the world and the people he cares about. I don't think it's inconsistent with the logic of the books to think the Elder Wand recognizes this, sees that the defeat isn't a true defeat. We already know that "defeat" is not synonymous with "kill" in the Elder Wand's eye.
Had Harry actually died in the clearing in the forest, the Elder Wand might have switched its allegiance, because the gamble wouldn't have worked. But I think the wand is extremely clever and able to read a little more into the situation than Voldemort, consumed by his hubris, has any hope to.