Simple, because we see the world through our eyes and judge people and situations through our experiences and exposure. Let me put it in simpler words, the way the other person behaves or responds to a situation depends on the way he thinks and the way he understands a situation. His response shows his attitude towards the current situation. But the perception is always yours. The world is the way you understand it.
For instance, a person might give alms to a beggar at the traffic or inform him about the need for labor in the next street. It is you who understands the person as a kind heart if he offers money to a beggar, or see him as selfish, who doesn’t help the beggar with the money he needs. You might also appreciate the person’s concern towards the self-respect of that so-called beggar to make him self-dependent.
Judging others depends on many things, but 95% depends on our perception and assumptions. The circumstances and surroundings we grew up, constantly play on our subconscious mind which further build our inner voice, and give us the power (though not exactly) to judge people accordingly.
A few conceptions based on some prejudices and a few cumulative actions we see, make us understand a person. But it is our initial duty to check whether what we understood is true.
This basic thinking puts you in their shoes and helps you understand the person. But one should have clarity in mind to welcome the positives and negatives of a character, completely. Remember, only an empty bucket can be filled !!