I noticed that in Matthew 27:9-10 the writer says Jesus' betrayal was the fulfillment of the prophecy in Jeremiah, but the quote in Matthew 27 from the OT is actually from Zechariah. Is there an explanation for this?
Matthew relies on a very common rabbinical technique of combining related prophetic passages to reveal meaning. In the case of Matthew 27, the author is blending Jeremiah 19:1-11 and Zechariah 11. In rabbinical tradition, when teaching from two prophets is blended into a single quote, the greater prophet receives the credit. In this case, Jeremiah is considered to be a greater prophet, so Matthew attributes the prophecy to him.
First, notice that Matthew says the words of Jeremiah were fulfilled by the betrayal of Christ for thirty pieces of silver, yet Matthew quotes words taken from Zechariah 11. It's important to note that the words quoted from Zechariah do not by themselves pronounce a prophecy as such, but rather they are taken from Zechariah's story concerning how he shepharded the flocks. His story was a picture of Christ's betrayal, yet his actual words were not prophetic.
So the picture of Christ's betrayal was provided in Zechariah's book, but the content of the prophecy concerning God's judgment of Israel is provided in Jeremiah 19:1-11. Therefore, Matthew says that the events of chapter 27 "fulfilled" Jeremiah rather than Zechariah, though he chose Zechariah's words to draw upon the picture of pottery, a polluted burial place and a rebellious people who treat the Lord with contempt. The fulfillment was of God's promise to judge Israel and make the land empty and polluted, because Israel rejected God, in the Person of Christ.