If someone thinks they are always doing the right thing, and believes others are wrong, what would I call them?
Say, for example, I did something that person considers wrong. But then on another occasion, the same person does the same thing I did and believes they are right. So they feel like they're an exception, but at the same time, others are wrong and can't act like that.
Self-righteousness (also called sanctimoniousness, sententiousness, and holier-than-thou attitudes) is a feeling or display of (usually smug) moral superiority derived from a sense that one's beliefs, actions, or affiliations are of greater virtue than those of the average person.
Self-righteous individuals are often intolerant of the opinions and behaviors of others.
Someone who is pharisaical preaches one thing and then does another — not a good trait for politicians or even playground pals.
Why use pharisaical when you could say hypocritical? In general, you would probably use the word in especially severe cases of hypocrisy, particularly when someone is not only a hypocrite, but acts superior and is being particularly annoying about it.
Hubris is an excess of confidence: a boxer who shouts "I'm the greatest!" even though he's about to get pummeled by a much stronger opponent is displaying a lot of hubris.
Hubris is from Greek, where it meant "excessive pride, violating the bounds set for humans" and was always punished by the gods. We no longer have the Greek gods, so in English it just refers to over-the-top self-confidence. If you call yourself the best in something, you better have the goods to back it up, since too much hubris can lead to embarrassment and humiliation. It's an age-old human failing: pride goeth before the fall.
You could go with grandiose, which makes it clear that this is an unrealistic sense of superiority that they are carrying around with them.
... a sustained view of oneself as better than others that causes the narcissist to view others with disdain or as inferior - as well as to a sense of uniqueness: the belief that few others have anything in common with oneself and that one can only be understood by a few or very special people.
When the talk is about the knowledge the closest term will be:
know-all | know-it-all (nounBritishinformal) – a person who acts as though he or she knows everything and who dismisses the opinions, comments, or suggestions of others. noun: know-all; plural noun: know-alls; noun: knowall; plural noun: knowalls
The closest informal synonyms would be:
smart aleck – noun, a person making wise remarks;
wiseacre - noun, one who claims full knowledge;
braggart – noun, a person who talks boastingly;
or even synonyms which describe even more negative attitude alike:
smart-arse | smart-ass - noun, a person who is irritating because they behave as if they know everything;
smarty-pants – noun, someone who wants to appear to be clever.
You may also consider the adjective arrogant, but the meaning would be a bit different – "a person having exaggerated self-opinion".
Consider "Psychopath" or "Sociopath" or "Narcissist"
Such people are known as narcissists and will hate you if you find fault with them. You cannot win with such people. They have a grandiose, inflated sense of self-importance. Narcissism is a mental illness and a serious personality disorder.