A comedy of errors often includes mistaken identity. It can also refer to mistakes made by foolish people.
One example of a comedy of error that we see in A Midsummer Night's Dream is Puck mistaking Demetrius for Lysander. After Oberon witnesses Demetrius being cruel to Helena in the woods, he orders Puck to use the magical flower on Demterius in order to mend Helena's broken heart. However, neither Oberon nor Puck realize that there are actually two Athenian couples in the woods that night; hence, Oberon only tells Puck that he will "know the man / By the Athenian garments he hath on" (II.i.269-270). Therefore, when Puck sees whom he thinks is Helena lying so far away from whom he thinks is Demetrius, he assumes that it is because Demetrius is being cruel to her, rather than that she is trying to preserve her chastity. Puck decides that he has indeed found the correct Athenian man and enchants his eyes using the magic flower. However, Puck has mistaken Lysander for Demetrius instead. The result is that Lysander awakens to see Helena and falls in love with her instead of continuing to love Hermia. This comedy of error creates great distress among all four lovers, even leading to a great fight in which Helena accuses both men plus Hermia of mocking her.
We also see a comedy of error with respect to foolish mistakes the mechanicals make. The mechanicals have visions of putting on a grand performance before the duke on his wedding day; however, the reality is that they are too uneducated and too unskilled to really put on the play they envision. Instead, they make ridiculous decisions concerning the play, which turn their play from a tragedy into a comedy. One foolish mistake is the decision to write a prologue to inform the audience that no one is truly killed in the play, which will especially appease the sensitive ladies in the audience. It is Bottom's idea to write a prologue that "seem[s] to say we will do no harm with our swords, and that Pyramus is not kill'd indeed" (III.i.16-17). This is especially ridiculous because of course the audience of a play already knows that the things done in a play are just for show. A second ridiculous idea Bottom has is to have an actor play the part of a wall and to "hold his fingers thus" in order to form a chink through which Pyramus and Thisbe discourse (64-65). This is ridiculous because it not only looks ridiculous, but it is also possible to build a mobile wall to use for the set. A third ridiculous idea that turns their tragedy into a comedy is the idea to have a man play the part of the moon. This is especially absurd because the actor comes on stage with, not only a lantern to represent the moon, but also, inexplicably, a thorn bush and a dog. All of these silly and foolish mistakes serve to turn their tragedy into a comedy, thereby serving as comedies of error.