Try to track down the specific trigger - when exactly you start comparing yourself to others. Maybe it's social media, a conversation with a friend, checking out other people's results at work? Once you identify the trigger, you can either avoid it or prepare yourself in advance. For example, if it's Instagram - just delete the app from your phone for a while, don't fight it. Yeah, you can reinstall it later, but a week or two without this miracle does wonders.
Second thing - when you do catch yourself comparing, don't beat yourself up and don't try to suppress the thought by force. Instead, write it down right away or just think: what do I actually know about this person? Where are their mistakes, their exhaustion, their failed attempts? You only see the finished result, but you don't see a single step or a single mistake along the way. This shift in focus works better than just "stop thinking about it."
And what really helps - keep a little list of your wins, even if they're microscopic. One thing every day that you did well or at least did despite everything. You don't need huge achievements. Over time you start comparing yesterday's you to today's you instead of comparing yourself to some Instagram girl, and that completely changes the game.