This is quite uncomplicated.
- What Jesus said as recorded in Matt 27:46 and Mark 15:34 is in Chaldean/Aramaic
- The language of Ps 22:1 is in Hebrew.
Note the terse comment of Meyer on Matt 27:46 -
σαβαχθαν? Chald.: ????????????? = the Heb. ????????????.
Now, because Aramaic/Chaldean is a related language to Hebrew (both are semitic) means that there is some resemblance in some words. Nevertheless, they are different languages like German and English - some words are the same but still different.
Benson is more explanatory:
Eli, Eli, lama sabachthani — These words are quoted from the first verse of the twenty-second Psalm. (where see the note,) but it is to
be observed, that they are not the very words of the Hebrew original;
but are in what is called Syro-Chaldaic, at that time the language of
the country, and the dialect which our Lord seems always to have used.
Mark expresses the two first words rather differently, namely; Eloi,
Eloi, which comes nearer to the Syriac. Some think our Lord, in his
agony, repeated the words twice, with some little variation, saying at
one time, Eloi, and the other, Eli. “This,” says Dr. Doddridge, “is
possible, and if it were otherwise, I doubt not but Mark has given us
the word exactly, and Matthew a kind of contraction of it.”