Mistaken identity (plot device)
Mistaken identity is a plot device whereby one person is taken for another and, often, vice versa. It is used in many comical plays, exemplified by the Shakespeare's Comedy of Errors, inspired by Menaechmi and Amphitryon by Plautus. In some cases mistaken identity involves disguise, e.g., accidentally identical costumes. Often it is a base of a romantic comedy.
William Shakespeare wrote some prominent examples of the use of this trope. For example, the Folger Shakespeare Library describes how the farce, The Comedy of Errors, "set out to multiply the opportunities for comic misidentification" with two sets of twins who were accidentally separated at birth, intensifying confusion throughout the play.