I don't think either were examples of lacking mental toughness.
Those had more to do with offenses that couldn't execute at a high enough level, consistently leaving the defense hung out to dry.
Against Stanford, Drew Pyne had far and away his worst game of the year. He couldn't hit water if he fell out of a boat that night. Capped off by a couple back-breaking and poorly timed turnovers and generally poor play calling from Rees.
Against USC, ND was missing 2 of their best defensive backs in a game they absolutely could not afford to be missing them, against the best QB in college football and he was on that night. That was a game where the offense needed to keep pace and cash in on opportunities, and while Pyne and the offense had a good statistical game, they failed to convert when it mattered. Again, that's more of poor execution than they simply lacked mental toughness.
Same thing in 2023. Louisville was a situation where the defense was mentally and physically exhausted after 8 consecutive weeks, 3 straight prime time games against undefeated opponents, 2 of which were on the road. The defense had to do everything in their power to hold things down, because, like 2022, the offense struggled immensely. Clemson was much of the same. Defense was holding it down, while the offense continued to execute poorly and the play calling left much to be desired.
I don't think the offense struggled because they weren't mentally tough. I think they struggled because they just weren't very good. Talent was definitely a problem at receiver and to some extent on the interior of the OL, and combine with a struggling QB and inexperienced and struggling play caller, that's not usually going to net you good results in games that matter.