Why did Matthew view Hosea 11:1 - being called out of Egypt - as a prophecy about the Messiah Jesus?

Bible passage: Hosea 11:1
Prophet: Hosea
Written: About 750 BC

In the book of Matthew, the author provided examples as to how important events in the history of Israel are reflected in the life of Jesus.

One example that Matthew provided is found in Matthew 2:15, which alludes to another Bible passage, one that was written centuries before:

When Israel was a child, I loved him, and out of Egypt I called my son. (Hosea 11:1, NIV)

During ancient times, when the nation of Israel was in its infancy, the Israelites left their homeland, which had been struck by famine. Escaping the threat of death from famine, they migrated to Egypt.

Generations later, God raised up Moses to lead the Israelites out of Egypt and back to the land of Israel.

When Jesus, who literally is the son of God, was an infant, Joseph and Mary took him to Egypt, to elude a threat of death from King Herod. After Herod's death, God sent an angel to inform Joseph, who was Jesus' adoptive father, that it was safe to bring Jesus and his family back to the land of Israel.

Matthew is giving us an example, in Matthew 2:15, of how Jesus' life is in parallel to the history of Israel, of how Jesus himself is the personification and perfection of Israel.