Being overconfident is a problem. Being confident isn't. Confidence is the (internal) certainty that you're in the right on something. Overconfidence occurs when you lack the ability to reexamine that position, and leads to ill effects (shattered ego after failure, posturing rather than persuading, inability to correct your course when in error).
When doing any task, you need to be confident that what you're doing is the correct thing to do, even if it's only an experiment and you accept that it may fail. When designing or writing a program, I choose a path, and proceed confidently. When I hit a dead end (a bad design, an unsolvable problem), because I'm not overconfident, I'm able to reexamine my choices and correct. If I lacked sufficient confidence to begin, I'd be stuck at the design stage trying to decide between the twenty different frameworks available, analysis paralysis. Or I'd be second guessing myself at each stage and progress would be remarkably slow.
When going out on the field or into a ring for a sport, you have to be confident in each movement so that the movement is fluid, deliberate. Lack of confidence induces hesitation, and hesitation is more likely to lead to failure (by some metric). Which creates a feedback loop continuing the reduction of confidence and the increase in hesitation, resistance to progress.
I think a better way of framing confidence and overconfidence is your ability to feel impacted by other people around you. If someone has reached the point where other people's reactions, thoughts, feelings, seem to hit a kind of armor and gets ignored or shrugged off, he is acting like an asshole.
It is one thing to feel confident while at the same time, one feels the connection with other people. When someone uses the feeling of being "right" as a shield, it veers into asshole territory.
This is obviously false, counterexamples are everywhere you look.