Overconfidence
Something I have noticed in my life and that seemingly affects others similarly is how vulnerable we are to overconfidence, and how much of a variable our surroundings and relationships are in the development of it. I think that the most reliable method to combat this less apparent form of overconfidence is not to merely self-reflect and hope to catch ourselves, but constantly surround ourselves with those better than us as a means of increasing our personal quality standards. The rest of this post is elaboration (and quite a bit too, woops).
In my opinion, there is a type of confidence that isn't a character trait, but is merely a subconscious reaction to how we're treated by those we respect (or disrespect). You probably have known somebody in your life who was genuinely the best in some aspect of life, and if they were constantly being told they were the best, and they knew they were in fact the best among those they knew, they most likely came off as cocky, even if they weren't "the type" to do so. Often this happens in niche communities where it is easy to completely dominate the space, people can get bigheaded quickly when they are not challenged. This may sound like I'm blaming others for the attitude of another person, but asking the world to simply stop praising others so that nobody knows how good they are at anything (that isn't empirically measured, such as sports) is practically impossible, so that isn't what I'm trying to say at all.
This kind of overconfidence where you are correct to think you are better than others at a specific thing and subconsciously develop an inflated ego I would call "true" overconfidence, as opposed to "false" overconfidence that someone who is mediocre may put forward in hopes that they are seen to be mightier than they are (a.k.a. posturing; this is the one I would attribute to someone's character, with the other owing to environment). This kind of "true" overconfidence, I believe, is not as distinct of a choice as the "false" variant, as there is a certain kind of honesty to it, and from my experience, it comes off differently than "false" overconfidence. I think it is up to the individual to keep this in check, although I don't think it's just as easy as not trying to appear overconfident or trying to be aware of your level of confidence, as that might lead to overcompensation and having you coming off as not confident at all (such as amazing artists who think being humble means calling all of their art bad; I suppose this can be called impostor syndrome, though this term is grossly overused).
The only exception I can think of in the case of being the best at something among their friends is when people surround themselves with those who are more exceptional than they are, whether that be in other friend groups or from outside influences such as spectating others' excellence or education. If you care about your own ego and how you appear to others, and you know you are the best at something compared to others you know, I think that the best way to avoid accidentally coming off as overconfident is to seek out people better than you (without becoming envious). This is advice that is common and obvious, but I think that this effect is a bit less obvious than the other benefits of having friends that challenge you.
I have found that knowing I am not the best at something has an effect on how much I think I know about a subject (such as physics or music), and I believe that this subconsciously affects how confident I appear to others. By taking physics classes and continuing my pursuit of a higher level of achievement, I think that keeps my confidence in that subject at bay, even when every person I tell my major to responds with "you're so smart I could never do physics haha."
This also might be the reason we see so many people graduate college thinking they know everything there possibly is to know. They're no longer being challenged or are surrounded by people who are better than them, nobody is there to tell them they're wrong, anymore, they no longer receive a bad grade or social embarrassment for inadequate work and therefore are more likely to lower their personal standards. This isn't anything novel, just another application.