Harry takes Draco Malfoy's hawthorn wand, not the Elder Wand. How, then, does he become the master of the Elder Wand, which he never took from its true owner (Draco), or touched? Does a wizard lose the allegiance of all his wands if even one of them is taken from him? Pretty risky innit?
Since Draco took the Elder Wand from Dumbledore's hand (and thus, 'defeated' him, via disarming), the allegiance of the Elder Wand passed to him (even though Draco didn't use it).
Later when Harry took the hawthorn wand from Draco, the Elder Wand knew that Draco had been "beaten" and it changed its allegiance to Harry Potter. It was simply waiting for him to gain possession of it.
This is a complicated topic.
What is not made clear in canon, but is explained later by J.K. Rowling, is the fact that
if a wizard or witch defeats another and earns the allegiance of their opponent's wand, all wands under the control of the opponent switch allegiance to the victor and it is possible for a witch or wizard to be the master of more than one wand at a time, and to lose the allegiance of more than one wand at a time. [Emphasis mine]
Draco Malfoy was master of both his hawthorn wand (the wand that chose him at Ollivanders when he was eleven) and the Elder Wand, following his disarming of Dumbledore on the Astronomy Tower the night Dumbledore was killed.
When Harry Potter defeated Draco Malfoy by taking Draco's wand at Malfoy Manor, not only did Draco's hawthorn wand switch allegiance to Harry, but the Elder Wand did as well. As noted, Draco never knew he was master of the Elder Wand at any point. Furthermore, the Elder Wand chose Harry as its master.
In Deathly Hallows, Voldemort says,
"But then, Potter, Dumbledore as good as gave me the wand!" Voldemort's voice shook with malicious pleasure. "I stole the wand from its last master's tomb! I removed it against its last master's wishes! Its power is mine!
To which Harry replies:
"You still don't get it, Riddle, do you? Possessing the wand isn't enough! Holding it, using it, doesn't make it really yours. Didn't you listen to Ollivander? The wand chooses the wizard . . ."
(Deathly Hallows -- Chapter 36)
J.K. Rowling has shared that the core of the Elder Wand is the tail hair of a Thestral, "a powerful and tricky substance that can be mastered only by a witch or wizard capable of facing death. J.K. Rowling Therefore, Voldemort would never have been able to truly master the Elder Wand, no matter how he came to possess it. Voldemort was incapable of facing death. As we know, Harry faced death twice, once unknowingly as an infant, once deliberately as a teen. Accordingly, Harry was able to both master and win the allegiance of the Elder Wand.
The wand's allegiance changes when its master is "defeated." Evidently, being disarmed counts, which I think makes sense. If you've disarmed a wizard, they're at your mercy, you've essentially defeated them. It doesn't matter whether the wand is present; since it is magical, it will know its master has been defeated, and by whom.
Yes, that is dangerous, but it's a dangerous wand.
In the book and the film "Harry Potter and the Half Blood Prince" it appears that Snape disarmed Dumbledore, from the way Harry was looking at it. In actual fact, Malfoy did disarm Dumbledore, but had no clue that he now possessed the wand. Lord Voldemort, in thinking Severus Snape had disarmed Dumbledore, destroys him with the Avada Kedarva curse. However since Snape did not actually disarm Dumbledore, the wand wouldn't cooperate with Lord Voldemort.
After looking at the Pensieve, Harry realizes that Snape was not to blame for Dumbledore's death and figures out that Draco Malfoy did disarm Dumbledore. After Harry Potter defeats Lord Voldemort, he actually explains to Hermione and Ron how he had just recently disarmed Malfoy, making Harry owner of the wand. However, seeing as the Elder Wand with its powers has caused so much trouble, wars and deaths alike, he places it back into Dumbledore's grave (in the book; in the film he snaps it in two), thinking the wizarding world would be much better without it.
Here is an attempt at a reply to the initial question. I think, and I am not well acquainted with the books, that it is a special feature of the elder wand, a special feature of "power", if you will, that its allegiance is of such a transient nature. However, in my point of view that is not necessarily intrinsic to ordinary wands just as much.
By disarming Dumbledore using Expelliarmus, Draco became the true owner of the Elder Wand. At Malfoy Manor Harry disarms Draco, meaning, unbeknownst to him, that the Elder Wand is his. However, Voldemort believes that you have to kill a person to get it, making it so the wand goes from Dumbledore to Snape to Voldemort. Ollivander senses Draco’s original wand’s allegiance has changed because he temporarily had possession of the Elder Wand. I assume that his first wand may have felt betrayed and from there I’m not positive about Draco’s first wand.............????
I think this makes more sense though: Draco disarmed Dumbledore therefore NOT defeating him. Snape killed Dumbeldore so the wand was then his. Voldemort killed Snape so the wand was then Voldemort's and Voldemort was killy by Harry but then Harry snapped the wand in two and threw it away:/does this make sense to anyone else but me?!