Why does he flirt with me in private but bullies and ridicules me in front of other people?

So I (F20) used to take this Spanish course and the professor (26M) seems to love to humiliate me and make the other course students laugh at my expense and is pretty impatient when i make a mistake or when I’m a bit slow when learning a new language, but he wouldn’t DARE do this to anyone else that was with me in the course, but he also seems to love making heavy eye contact with me and flirts when we’re alone…
I didn’t wanna take any of his bullshit no more so I dropped the course but I’m just so confused, so guys what was the reason for him treating me this way?
Why does he flirt with me in private but bullies and ridicules me in front of other people?
Post Opinion