Matthew 2:22

Warned in a dream (crhmatisqei kat onar). He was already afraid to go to Judea because Archelaus was reigning (ruling, not technically king, basileuei). In a fret at last before his death Herod had changed his will again and put Archelaus, the worst of his living sons, in the place of Antipas. So Joseph went to Galilee. Matthew has had nothing about the previous dwelling of Joseph and Mary in Nazareth. We learn that from Luke who tells nothing of the flight into Egypt. The two narratives supplement one another and are in no sense contradictory.