This question already has an answer here:
- Why didn't Harry die in the dark forest? 5 answers
Among all his other inert Horcruxes, Voldemort created two living ones: Harry and Nagini.
When Voldemort tried to kill Harry, he was unable to do so. Instead, his curse ended up killing the piece of Voldemort's own soul that Harry carried. Logically, this means that when a living creature, that's also a Horcrux, is killed, it's not the carrier, but the soul they are carrying, that ends up dead.
However, this reasoning does not seem to work for Nagini. She was holding a piece of Voldemort's soul when she was killed, but both souls were destroyed. Shouldn't Nagini, the snake, have survived, and only Voldemort's soul died?
Even if we accept that physically killing Nagini killed both souls, how is that any different than magically killing Harry? How did the killing curse "know" which of the two souls inside Harry's body should die?