Whom does Hamlet accidentally kill, and why?
Hamlet accidentally kills Polonius because he thought that he was Claudius, listening in on he and his mother's private conversation behind the curtain.
In Act 3, scene 4, Hamlet is called to his mother's chamber so that she can question him about his actions during the play that he put on. However, Hamlet quickly turns it on her, and begins to violently question her about her actions in forgetting about her last husband's death and marrying Claudius.
Since Hamlet is getting aggressive -- normally, productions portray him as grabbing her and pushing her up against the mirror, that she might see herself and her sin -- Gertrude is afraid that Hamlet, in his madness, is going to kill her. So she yells for help.
What Hamlet doesn't know is that Polonius is hiding behind an arras in Gertrude's room, and Polonius quickly calls for help too, thinking that the Queen is in danger. Hamlet thinks that the man hiding there is Claudius, whom he wants to kill, so he stabs Polonius through the curtain.