Did Matthew misquote Jeremiah and Zechariah?

In Matthew 27:9-10, the writer ascribed to Jeremiah the well known prophecy of Zechariah 11:12-13.
Please explain why he did so.

Was Matthew as a pious Jew, long in the companionship and service of our Lord, and a man of apostolic gifts, likely, quite apart from the inspiration of the Holy Spirit, to confuse the prophets Jeremiah and Zechariah? Here he was engaged under the direct guidance of the Spirit, in writing a book which was to live down the ages, and which he, as a mere man, was perfectly incapable of producing. Infidels have foolishly boasted sometimes that they could write as good a book as the Bible. They ought to do it then, for it would pay them well. It would be a “best seller” for years. Matthew plainly was familiar with Zechariah, as his quotation in Matthew 21:4-5 shews, and could not have confused the books, even with his own intelligence alone.

The probable explanation is the one cited by Lightfoot, that Jeremiah, as considerably the longest of the prophets, had the first place among them, and so his name came to be used for the volume of the prophetical writings. He quotes the learned David Kimchi as his authority. We often speak of the Psalms ofDavid, without affirming he wrote them all. There is another explanation which may also be the true one. The expression, “spoken by Jeremy the prophet,” may refer to some well known word of the prophet, just as Paul in Acts xx refers to words of our Lord: “It is more blessed to give than to receive,” which are not recorded in the Gospels. The quotation of Matthew does not agree exactly either with the Hebrew or LXX of Zechariah 11. Sometimes the prophets did receive messages as to the same events in almost identical language. Supposing, for instance, some New Testament writer had quoted Micah 4:1-3, and it had not been recorded that Isaiah had said the same words in chapter 11:2-4 of his prophecy, and we had read that the well-known words of Micah “were spoken by Isaiah the prophet,” how eagerly critics would have seized upon it as a mistake! Of one thing we may be sure, Matthew, an inspired apostle, chosen of God for this wonderful ministry, did not make a mistake.