Great question, and I think some of the answers above are great.
Let me add a few more remarks:
Tennis is a difficult sport because we are battling against an opponent on our own, we lose many points even if we are playing well, and a match is not won until we complete the last point successfully. So it is normal that our emotions will shift throughout a match, and the goal is to try and be in our best performance state as much as possible ( and not all the time).
So my first comment is, we need to drop perfection, and be compassionate towards ourself for trying our best and hanging into a match, even when we feel less motivated.
Now the secret to really amplifying your motivation is to enjoy a match beyond just specific outcomes that we can't always control, like winning. Instead, we want to find a purpose that goes beyond winning,. For example this might mean to enjoy the challenge of pushing your limits and developing your character by developing traits like focus, discipline and resilience.
In this case its important to think of character traits you want to develop both off and on the tennis court, create a training plan to develop one character trait at a time and then use your matches to show case those traits.
You might also enjoy competing because you know that ever match will help you learn new skills that will help you become a better tennis player.
In that case you want to create a ritual whereby you analyze matches so you can learn from them and improve.
Or you might love competing because you love celebrating wins with your loved ones.
In that case, you need to of course accept you can't always win but at the same time visualize winning matches and then celebrating with your coach, your partner and your support team.
The key here is that you need a strong WHY that will justify your hard work and your efforts to become the best tennis player you can, and to give your best throughout your matches....