I think some players have an innate nature where they hate to lose and it is easier for them to make adjustments necessary during a match to increase their chance of winning. So, if you hate the agony of defeat, you probably will compete hard on every point and will be mentally tough.
The other key is to stay at an optimal stimulation range that promotes peak performance throughout a match. If you get stressed, tight, emotional, angry, believe your opponent is too good etc., you get over-stimulated over the optimal range. If you get over-confident, relax too much after winning a set or getting a break or being up 40-0, get bored, think of issues like work/family while playing, stop caring about the outcome, start hating your opponent‘s style of play, you will get under-stimulated below the optimal range. If you are over-stimulated, you have to relax and calm down and deep-breathing, verbal mantras, visualization of peaceful images etc. can help to get back into optimal range. If you are under-stimulated, taking fast/shallow breaths, jumping up and down (like Nadal does sometimes) between points, verbal mantras etc. can help you get back into optimal range. Also, worrying about playing the ball and the point rather than focusing on the score helps some players to stay relaxed.
I have recommended a book called “SMART TENNIS” by a sports psychologist John Murray in many threads - it helped me a lot on the mental aspects of playing tennis, much more so than better-known books like ‘Inner Game of Tennis’, ‘Winning Ugly’ etc.