How could I stop myself from trying to prove everyone wrong? Like if someone makes a comment about me saying I would never do something, because it’s bad, I will sometimes do it to prove them wrong. Then later I will regret it. How can I stop myself in that moment?

Peer Z.
It’s a good thing you recognize the problem. Although it isn’t a much reliable option, I guess you could try to pause in that moment right before you do something to prove someone wrong, and think about why you’re doing it. Maybe write a list of reasons why you shouldn’t do things just out of spite, and consult it whenever you feel the urge to.
Lenny Q.
Self-awareness through mindfulness will make you aware of your thoughts and how the world is affecting you. This grants you an autonomy of mind to give you agency over your actions and reactions. Jessie Zhu at Positive Psychology says "Our mind is extremely skillful at storing information about how we react to a certain event to form a blueprint of our emotional life. Such information often ends up conditioning our mind to react in a certain way as we encounter a similar event in the future. Self-awareness allows us to be conscious of this conditioning and preconceptions of the mind, which can form the foundation of freeing the mind from it.” The mind can control your behavior as long as you aren't consciously paying attention to it. You don't have to always be defined by it. And meditation is not the only way to accomplish this, but it is proven to be extremely effective.