The Gospel According to Saint Matthew was written anonymously and was not attributed to Matthew until later in the second century. Matthew could not have been the author, as he is listed as a disciple of Jesus and would therefore have had first-hand knowledge of the life of Jesus, yet scholars have shown that Matthew's Gospel was largely derived from Mark's Gospel and from the Q Document.
The Gospel of Matthew was attributed to Matthew because the internal evidence, style and focus all point to the eyewitness account of the tax collector Matthew. No other author is probable or necessary.
The four New Testament gospels were originally anonymous and were only attributed to the apostles whose names they now bear, later in the second century. Thus we only have the opinions of the Church Fathers as to who any of the authors were. As the gospels became widely circulated and studied, the Church Fathers saw that there were undoubted literary dependencies among the gospels. They believed that Matthew, the disciple of Jesus, wrote the first gospel and that the gospels they attributed to Mark and Luke were based on copying and improving Matthew's Gospel. In fact, scholars now say that none of the gospels could have been written by an eyewitness to the events they portray.
Scholars can demonstrate that Mark's Gospel was actually the earliest gospel and that Matthew's Gospel was largely based on it, with some 600 of the 666 verses in
Mark, as well as containing further sayings material from the hypothetical 'Q' document. Clearly, a disciple of Jesus would not have need to base almost his entire gospel on these prior sources. Matthew did not write the Gospel of Matthew.