In the Harry Potter series, it is known that Professor Severus Snape tries to protect Harry.
This is because, as a Hogwarts student himself back in the day, he fell in love with Lily (Harry's mother). But she chose 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 Gryffindor.
Snape hated Harry, but in the first movie during the Gryffindor vs Slytherin Quidditch match, Quirrell 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 Quirrell didn't do it again. That was in the book.
But I don't understand the motivation of Snape's hatred towards Harry Potter in the first few years.
But towards the last few years, Snape showed that he cared and protected Harry without hesitation.
Why did Snape hate Harry to begin with?
"I'll make sure you two-three are expelled next time something like this happens again"