Self doubt is like a poison. It usually starts with someone else. They pierce your ego with a barb that introduces the possibility that you may be wrong. From there it can slowly work its way around until at last it has consumed your very worldview. No action you make is free from analysis by your own conscious. Like a cytokine storm, your body works against you. Purging self doubt is a long and laborious process, with varying degrees of difficulty depending on the source of your doubt. The more respected the source, the harder the purge. Complete sublimation of insecurity often requires that the initial source acknowledge their own mistake in doubting you.
What can you do?
Two things: surround yourself with vapid yesmen and support your ego through the lack of complaint from those around you. This is an easy but dangerous method, as it lacks any doubt whatsoever. This may lead to unrealistic worldviews and harmful decisions as a result.
The second method is much harder, but much more healthy. Learn to accept criticism without internalizing it. Discover the truth of the statement: if someone says something about you, no matter how much you respect their opinion, it isn't always true.
Both are a sort of armor against the poisonus effects of doubt. Like all things, however, doubt has a place in the psyche too. Learn to understand your failings, to accept them, to be aware of when your failings are affecting your judgment. Every human has flaws; that is why we are human, however, flaws don't entail correction in every situation. To attempt to perfect yourself, you merely deny your nature and create a perverse mockery of your self. You must embrace your flaws, live with them. Self awareness is truly the path to enlightenment.
However, remember this: self awareness and self conciousness are not the same. The importance of embracing your flaws is not that you attempt to fix them, but that you understand them and know them well, so the next time someone attempts to poison you with self doubt through one of these flaws you can dismiss it as irrelevant, since you're already aware of this part of yourself.