The gospel now known as Matthew's Gospel was originally anonymous. According to Eusebius, writing in the fourth century, Papias attributed a gospel to Matthew early in the second century, but some scholars are uncertain whether the gospel of which Papias spoke was the same gospel as is now widely attributed to Matthew.
As Matthew was a disciple of Jesus, we can at least determine whether our gospel was written by an apostle by establishing whether it shows signs of having been written by an eyewitness to the events portrayed. The late second century Church Fathers not only decided that Matthew's Gospel was really written by Matthew himself, but that it was written in the Hebrew language, which would help establish apostolic authorship.
Modern scholars say that the gospel was definitely written in the Greek language, and that it could not have been written by an eyewitness to the events portrayed. Whenever quoting or alluding to the Old Testament, the gospel uses the Septuagint (LXX) and not the Hebrew text. When a Greek version is laid in parallel with Mark's Gospel and Luke's Gospel, it soon becomes apparent that both Matthew and Luke were substantially based on Mark, with Matthew copying some ninety per cent of Mark, often using exactly the same words in the Greek language. Uta Ranke-Heinemann says in Putting Away Childish Things, page 218, it is incomprehensible that an eyewitness (the Apostle Matthew) would choose to depend so radically on a non-eyewitness (the author of Mark). She adds that the real author of Matthew is unknown. https://christianity.stackexchange.com/questions/35858/did-matthew-the-tax-collector-author-the-gospel