There is no historical consensus on the person of Matthew. There are several conflicting accounts, and the Greek text does not state anywhere he was an eyewitness (and therefore a disciple).
Clement of Alexandria quotes Heracleon, one of the earliest commentators on the New Testament, as saying that Matthew died naturally:
“But neither will this utterance be found to be spoken universally;
for all the saved have confessed with the confession made by the
voice, and departed. Of whom are Matthew, Philip, Thomas, Levi, and
many others.” —Stromata
But while earlier records are often assumed to be more reliable (because they’re closer to when the events actually happened), most scholars don’t accept Heracleon’s account today. All the other early records of Matthew’s death claim he was martyred, but they disagree about how and where it happened. The early church fathers said he was burned, stoned, stabbed, or beheaded.
The problem is the gospel of Matthew is anonymous: the author is not named within the oldest surviving text, and the superscription "according to Matthew" was added some time in the second century, although the gospel doesn't state it's an eyewitness account. The historically very likely incorrect tradition that the author was the disciple Matthew begins with the early Christian bishop Papias of Hierapolis:
From "New Testament Foundations: An Introduction for Students"
The consensus is that Papias does not describe the Gospel of Matthew as we know it, and it is generally accepted that Matthew was written in Greek, not in Aramaic or Hebrew. See Ehrman, Bart D. (1999). Jesus: Apocalyptic Prophet of the New Millennium. Oxford University Press.