How did Matthew know that Hosea 11:1 was about Jesus? How did Matthew know that Hosea 11:1 was about Jesus?


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


Even looking at the context of the verse, I see no clues that this means anything more than the simple fact that God brought the Israelites out of Egypt, freeing them from slavery.

When Hosea 11:1 was written, did people already realize that it was about the messiah, or was Matthew the first person to note it and revealed it for the first time in Matthew 2:13-15?

If it's the latter, how did he discover it? Is it really a prophecy if it's only revealed after it's fulfilled?

If it's the former, how did people know they were messianic prophecies?
“I see no clues that this means anything more than the simple fact that God brought the Israelites out of Egypt, freeing them from slavery.” 

There appear to be clues in the context of Hosea 11 and the following verses that allude to more than an act accomplished in history, Jon. Read at least through verse 11.

11 they shall come trembling like birds from Egypt,
    and like doves from the land of Assyria,
    and I will return them to their homes, declares the LORD.

This chapter appears similar to Ezekiel 36-37 and Isaiah 40-55 in that it speaks of prophecies concerning Gods covenant love. Hosea was not only speaking of the history of YHWH bringing Israel out of Egypt but was also pointing to a time when He would again rescue Israel and fulfill His promises to her. 

In the time of Jesus I don’t think many Israelites believed God had fulfilled his promises. They were in exile to Rome. They were waiting rescue. They were very possibly waiting for the fulfillment of the Hosea 11 prophecy.
When Jesus comes he seems to be saying through his words and actions, “I am the one you have been waiting for. Through forgiveness of sins and following me, I will save you from exile. I am your King”.
When Mathew quotes Hosea and says in 2:15,

“out of Egypt I called my son”,

he is not simply saying that since Israel came out of Egypt and so did Jesus, that therefore Jesus is the fulfillment of this passage. He is saying that Jesus is the embodiment of all that Israel was waiting for within the context of the promise of this Hosea passage.
N.T. Wright gives a persuasive argument in “The New Testament and The People of God. 

“What the early church is saying, when telling the story of Jesus’ resurrection and announcing it to the world as the summons to obedient faith, is that the history of, and promises to, Israel had come true in Jesus, that in his death and resurrection he had inaugurated the real return from that real exile.”  (NTPG chp.13 pg. 400)