In the Harry Potter series, it is known that Professor Severus Snape tries to protect Harry.
Reason for being is because as a Hogwarts student himself back in the day, he fell on love with who was Lily (Harry's mother). But she had an affair with James Potter.
Because Snape instantly knew that Harry was Lily's son, he dedicated to protecting Harry in the mid to last years of Harry being at Hogwarts.
But as we know, Snape, in the first few years, Snape hated Harry and deducted many points from Griffyndor.
Snape hated Harry, but in the first movie during the Griffyndor vs Slytherin Quidditch match, Quirrel is said and proven to be the one that tried to kill harry by throwing him off his nimbus 2000. But Snape intervened with a counter- curse to save Harry.
Snape even refereed the second match of Quidditch to make sure Quirrel didn't do it again. That was in the book.
But I don't understand Snape's motivation in the first few years of hatred towards Harry Potter.
But towards the last few years, Snape showed that he cared and protected Harry without hesitation.
Why did Snape hate Harry to begin with?
Especially saying:
"I'll make sure you two-three are expelled next time something like this happens again"