James didn’t change for Lily.
Hear me out though!
James didn’t start maturing until what? Sixth/seventhish year? You know what also happened between that time frame? Sirius running away. Sirius left to live with the Potters and if James truly wanted to change for Lily, don’t you think he would have done so years ago? If he wanted to change for Lily, he could have. But no, it was Sirius I believe who made him grow up a little more. He saw how bad of a home Sirius came from and I can imagine Euphemia and Fleamont taking James aside and telling James that he needed to show what a good influence was like because Sirius only really listened to James. James was the one person that Sirius cared for with all of his heart. So, James began to become more responsible, less arrogant, more friendlier and a lot kinder because that was what Sirius needed.
James didn’t change for the girl. He changed because he didn’t want his best friend going down the wrong path.