Mark begins his book by drawing attention to the words of Malachi.
Behold I send my messenger ... Malachi 3:1
But there are two messengers in the quotation that follows. The messenger of preparation (who we know is John the Baptist) and the Messenger of the Covenant whom Malachi expressly states is :
The Lord whom ye seek.
Since the Lord himself, come in flesh, is the Messenger of the Covenant thus Mark quotes his exact words (in Aramaic) - Eloi ! Eloi ! - since that is what his book is about - Jesus Christ come to express the Message, the Everlasting Covenant of the New Testament.
But Matthew draws attention to the King (of the Jews) and the Kingdom (not of earth but of heaven). Thus Matthew's focus is the transition from the passing phase of limited revelation within the compass of the nation of Israel into the full revelation to the whole earth through the Apostolic word of the Everlasting Gospel.
Thus Matthew draws attention to the Hebrew scripture. He does not quote the dialect in which Jesus spoke - he quotes the Hebrew words from the Psalm of David the King - Eli ! Eli !
My God, My God, why hast thou forsaken me ? ... Psalm 22:1
And why was it so ?
How could God ever forsake his servant in whom he delighted ?
Because God spared not his only begotten Son, but delivered him up for us all. That Divine Righteousness might be satisfied, sins must - they must - be resolved in humanity. Not the unclean and compromised humanity of Adam or any of his sons, but in Another Humanity, come of woman, but not come of Adam.
Thus the shocking rift in Deity, between God in heaven and God in humanity. That perfect unity of Father and Son - in One Divine Spirit - was disrupted. And for whom ?
For a vast multitude - as the sand of the sea and as the stars of heaven - whom no man can number.
I believe this cry came from the crucified Jesus spontaneously in the depths of unimaginable suffering when he experienced that appalling separation from the Father which was essential to the resolution of the sins of men.
And I believe that David was granted to prophesy of that moment in his Psalm.
Jesus is not - actually - quoting the Psalm, I would say.
It is the Psalm which, a thousand years before the event, is quoting Jesus.
Jesus cried out (spontaneously) in his native dialect of Aramaic.
David (the King) records it, in spirit, in prophecy, in Hebrew.
Thus Mark notes the actual cry of the Messenger.
And Matthew quotes the Hebrew Psalm of David.