Correction: Shakespeare did write The Comedy of Errors (c. 1594). It was inspired by Plautus's Roman comedies Menaechmi and Amphitryon—both built on twin mix-ups and mistaken identity. Shakespeare adapted these for his company, the Lord Chamberlain's Men, likely as a vehicle for their comic actors and to showcase his skill in farce and structural complexity.
The play's tight, chaotic doubling demonstrates his early mastery of classical form adapted for Elizabethan stage.