How does the Catholic Church reconcile the two different narratives of behavior of the thieves in Calvary as reported in Mt 27 and Lk 23?
A little background information is helpful before continuing on.
The Penitent Thief, also known as the Good Thief, Wise Thief, Grateful Thief or the Thief on the Cross, is one of two unnamed thieves in Luke's account of the crucifixion of Jesus in the New Testament. The Gospel of Luke describes him asking Jesus to "remember him" when Jesus arrives at his kingdom. The other, as the impenitent thief, challenges Jesus to save himself and both of them to prove that he is the Messiah.
He is officially venerated in the Catholic Church. The Roman Martyrology places his commemoration on 25 March, together with the Feast of the Annunciation, because of the ancient Christian tradition that Christ (and the penitent thief) were crucified and died exactly on the anniversary of Christ's incarnation.
He is given the name Dismas in the Gospel of Nicodemus and is traditionally known in Catholicism as Saint Dismas.
The Church is rich in traditions in this area.
For example there is an ancient tradition (not that all Church traditions are true), that the Crucifixion of Christ was on the Feast of the Annunciation (March 25), the same day St. Dismas is venerated as a saint! At least two of the Early Church Fathers believed this to be so.
See my question here: Did the Annunciation and Good Friday coincide?
Back to the question at hand, we will have to take a look into some of the apocryphal writings that were in circulation within the faithful in the Early Church.
Luke's unnamed penitent thief was later assigned the name Dismas in an early Greek recension of the Acta Pilati and the Latin Gospel of Nicodemus, portions of which may be dated to the late fourth century. The name "Dismas" may have been adapted from a Greek word meaning "sunset" or "death". The other thief's name is given as Gestas. In Syriac Infancy Gospel's Life of the Good Thief (Histoire Du Bon Larron French 1868, English 1882), Augustine of Hippo said, the thief said to Jesus, the child: "O most blessed of children, if ever a time should come when I shall crave Thy Mercy, remember me and forget not what has passed this day."
Anne Catherine Emmerich saw the Holy Family "exhausted and helpless"; according to Augustine of Hippo and Peter Damian, the Holy Family met Dismas, in these circumstances. Pope Theophilus of Alexandria (385–412) wrote a Homily on the Crucifixion and the Good Thief, which is a classic of Coptic literature. - Penitent Thief
In some of the apocryphal writings, Dismas helped out the Holy Family in the desert from other brigands while fleeing Herod’s edict to kill all children two years old or younger. Thus we can see how Dismas would have been more likely to follow the prompting of the Holy Spirit at the moment of crucifixion on his cross.
In the Golden Legend, the impenitent their was one of a band of robbers who attacked Saint Joseph and the Holy Family on their flight into Egypt. Dismas tried successfully to save the Holy Family from harm, even though he himself was a brigand.
Nothing in what I have written here is dogmatic truth according to Catholicism, but it does help us understand the nuances of some of the Church’s traditions in this matter. Each member of the Church is free to accept or not this as proof. In any case, it does help us understand things not fully comprehended.