People always have intentions, motivations. When a person treats you the way they do, there's always motivation behind. Maybe because they want you to feel bad about yourself therefore they feel better about themselves. Maybe because they want to teach you a lesson as they were taught. There's always reasons behind their actions.
In our life, we meet people who we thought are our friends. They smile and make you feel like you can trust them. They smile to make you feel warm and make you stand your guard down. They make you feel like they are not on to something, to make you feel secure and relaxed.
And when things happen, especially when you fail and they succeed (at a test, or a task), they declare their false humility and look at you like you're a lesser of a human being than them.