Matthew has a different twist from Luke to the nativity. In Matthew it’s Joseph rather than Mary who dreams of angels bringing messages from God. After the birth of Jesus in Bethlehem the holy family are forced to flee for safety to Egypt. They spend some time, maybe two or three years, as refugees there. They return to their own country on the death of Herod. However, rather than stay in Bethlehem they decide it’s safer to move up north to Nazareth.
We don’t hear anything about their time in Egypt, but presumably like any refugees, they have difficulty learning the language and customs of this foreign land with its ancient but very different culture from that of Israel. Imagine a young, newly married couple with a new baby forced out of their own country and all the people they know, trying to make their way alone in a foreign land.
Source: Jesuits in Britain