Here Jesus was not warned to flee, but the angel warned Joseph in a dream.
God did in a dream.
Joseph was warned in a dream to take the young child and his mother and flee to Egypt untill he hears from God again. (Matthew 2.13) So "the holy family" that fled to Egypt, were Joseph and Mary and Jesus.
Egypt
An angel came to Joseph in a dream and warned him to take his family to Egypt immediately as Herod was looking for the child jesus.
God warned Joseph in a dream to take Mary and Jesus to Egypt to avoid the wrath of Herod.
Jesus escaped to Egypt from Bethlehem, not Nazareth. King Herod, who wanted to kill him, ordered the massacre of all infant boys in Bethlehem, prompting Joseph and Mary to flee to Egypt with Jesus to keep him safe.
It seems to me that there is a gap in the story of Jesus.His parents flee to Egypt with him and he next appears grown up. What happened in between?
EgyptMat 2:13 Now when they had departed, behold, an angel of the Lord appeared to Joseph in a dream, saying, "Arise, take the young Child and His mother, flee to Egypt, and stay there until I bring you word; for Herod will seek the young Child to destroy Him."
If you mean Mary, the mother of Jesus, she was a refugee because they had to flee to Egypt so that Herod would not find and kill Jesus.
Mary , Joseph and the baby Jesus fled in the night to Egypt.
Actualy Mary and Joseph fled only once to Egypt from king Herod.
The death of King Ptolemy caused the Auletes to flee Egypt.