"Out of Egypt Have I Called My Son"
Old Testament: Osee 11:1
... Because Israel was a child, and I loved him: and I called my son out of Egypt.
New Testament: Matthew 2:13-15
... Arise, and take the child and his mother, and fly into Egypt: and be there until I shall tell thee... he was there until the death of Herod: That it might be fulfilled which the Lord spoke by the prophet, saying: Out of Egypt have I called my son.
The connection
Osee's oracle looks backward, not forward, his line is a memory of the Exodus itself, God's tenderness toward the infant nation He once rescued from Pharao. Matthew reads this same sentence and, without altering a word of it, points it forward instead: Joseph carries the infant Christ down into Egypt and back out again, and the Evangelist states plainly that this happened "that it might be fulfilled which the Lord spoke by the prophet" (2:15). A verse about the nation's past becomes, with no change to its own wording, a verse about the Messiah's history.
Moral sense
Being God's beloved son doesn't exempt Israel, or Christ, from exile, it only guarantees the calling-out that follows it. The danger comes first in both stories; the deliverance is what the danger is for.
Anagogical sense
"Jesus' departure from Egypt recalls the exodus and presents him as the definitive liberator of God's people" (CCC 530). What happened once, provisionally, to a nation happens now, completely, in the one person who was always what that whole nation's story was pointing toward.
The Fathers
St Jerome notes that in Osee the true Hebrew text has my son where the Septuagint has his sons, calling it "a passage which refers primarily to the mystery of Christ" (Letter 57 to Pammachius, 7), and says that when Matthew quotes the Old Testament "he does not follow the authority of the translators of the Septuagint but the Hebrew," giving this verse as his example (Lives of Illustrious Men 3).
Warrant
Checked in the Greek, and the result sharpens the citation rather than weakening it. The Septuagint of Osee 11:1 reads ex Aigyptou metekalesa ta tekna autou, out of Egypt I called his children, while Matthew 2:15 reads ex Aigyptou ekalesa ton huion mou, my son, agreeing with the Hebrew, which has ben, son, in the singular. Matthew is therefore not echoing the Greek Bible he ordinarily quotes but citing the prophet deliberately, which is what his fulfilment formula claims.
Catechism of the Catholic Church, paragraph 530.