Why are we generating wrong ideas in the first place? In CBT they tell you to challenge automatic thoughts.
So say someone doesn't say hello to you, then you think he doesn't like me.
CBT says to challenge this and maybe you realize that he didn't see you actually.

I have a more philosophical question in such sense.
CBT assumes that at some point we are generating wrong ideas (automatic thoughts) and later we are able to correct them ourselves.
My question is, if we are able to correct them, why are we generating the wrong ideas in the first place? What is the mechanism that allows this to happen? Which mind processes are in play here? Concious/unconcious?
I suspect we adopt irrational positions when we have an implicit choice available and our frame of mind, owing to biological factors such as stress hormone levels, favors rapid choices over thoughtful reflection on the circumstances we face. Dual process theory provides a decent framework for thinking about this. 

There is a remarkable body of literature examining paranoid ideation and social anxiety produced by D. Freeman which examines something along these lines experimentally. Attributional styles seem to be learned, then reinforced by exposure to stressful situations. Sort of a "feedback loop" of distorted cognition.