We stereotype because we all have a need for patterns and predictability to varying degrees and catagorising people based on appearance or other things helps us do this.
It’s when we start to project things (attitudes, preferences, intellect, skills) on to these stereotypes that it becomes prejudice and ignorance because you treat people based on your perception of them, not how they actually are.
As for discrimination, I would say that’s quite seperate from stereotyping. Since discrimination is differential treatment based on age, gender, family status, race, religion, sexual orientation, etc. Whereas stereotyping is often a case of ‘jumping to conclusions’ that may or may not be true.
There can be cases involving both discrimination and stereotyping, but I think they are two very different things (both are bad and wrong though)
note: I am of course using ‘we’ and ‘you’ as a generic terms