The entire plot of the end of the Harry Potter series relies on the fact that Harry won the allegiance of the Elder Wand by taking a different wand from Draco Malfoy, the current master of the Elder Wand. How did Harry know that he could gain the allegiance of one wand by winning a different wand from the same owner?
I am not asking if this is how it works, or why this is how it works, or if it makes sense that this is how it works. I am only asking how the character Harry was aware that this is how it works.
As far as I can tell, all his information about wand allegiances came from his conversation with Ollivander at Shell Cottage. However, I don't see anywhere in that discussion that Ollivander informed Harry of this fact.
And if one were to suggest that Harry wasn't actually sure that this is how it works, and he was taking a gamble, the question on that would be that surely he would've asked Ollivander about this rather than just blindly hope that this was the way it worked.