What's the solution? It's not as easy as educating students about growth mindset or long-term rewards of failure. They wouldn't absorb it the way you intended. Most failures don't necessarily motivate to improve. In fact, I think they result in people dropping out. It takes a long series of failures before you accept it as a part of the process.
I have read many theories surrounding how we can make our kids strive, make them resilient, and compassionate. So far, none of them have sounded convincing. There are probably many hidden factors involved and I guess it mostly boils down to: environment and luck.