Please see the larger context of the verse, Matt 27:3-10 (ESV):
³ Then when Judas, his betrayer, saw that Jesus[a] was condemned, he changed his mind and brought back the thirty pieces of silver to the chief priests and the elders, ⁴ saying, “I have sinned by betraying innocent blood.” They said, “What is that to us? See to it yourself.” ⁵ And throwing down the pieces of silver into the temple, he departed, and he went and hanged himself. ⁶ But the chief priests, taking the pieces of silver, said, “It is not lawful to put them into the treasury, since it is blood money.” ⁷ So they took counsel and bought with them the potter's field as a burial place for strangers. ⁸ Therefore that field has been called the Field of Blood to this day. ⁹ Then was fulfilled what had been spoken by the prophet Jeremiah, saying, “And they took the thirty pieces of silver, the price of him on whom a price had been set by some of the sons of Israel, ¹⁰ and they gave them for the potter's field, as the Lord directed me.”
The quotation in verses 9-10 came from Zech 11:12-13 (ESV):
¹² Then I said to them, “If it seems good to you, give me my wages; but if not, keep them.” And they weighed out as my wages thirty pieces of silver. ¹³ Then the Lord said to me, “Throw it to the potter”—the lordly price at which I was priced by them. So I took the thirty pieces of silver and threw them into the house of the Lord, to the potter.
You can see that "me" is not referring to the author of Gospel of Matthew. (See this explanation of why Matthew said it was Jeremiah, not Zechariah.)
The author of the Gospel of Matthew is traditionally the tax collector Matthew whom Jesus called to be one of the 12 apostles (see Matt 9:9).