Do you want to help this person be better, or do you want to protect yourself from them?
The first will require that they are receptive in some way to being helped, so it may be impossible.
The second… well, you’ve described a deeply insecure person. The need to constantly remind other people how much better they are demonstrates a real fear of being found to be inadequate. If you can determine the source and/or subject of the insecurity you can potentially weaponize it against them. That’s risky though, it may make you more of a target for retribution.
Remember, you can’t fix someone else, they can only fix themselves. You can offer guidance, but that only works if they’re open to being guided.
Perhaps the best course of action is more zen… let them learn their own lessons. Isolate yourself from damage as much as possible, and just wait for them to crash and burn. Make popcorn.