From the moment Severus Snape was introduced in Harry Potter and the Sorcerer's Stone, he was viewed through Harry's eyes as a villain. Harry obviously reminded Snape of his father, James, who had bullied and tormented Severus all throughout their time at Hogwarts together. But there was far more to Snape's story than anyone could have ever guessed. It was known throughout the story that Snape was a double agent, working for Dumbledore and reporting the Dark Lord's movements while feeding Voldemort as much information as he could about the opposition. However, there were a lot of people who didn't believe Snape was actually loyal to Hogwarts' headmaster, including Harry and his friends. Between Professor Snape and Albus Dumbledore, Harry had a full arsenal watching his back while he was at school.
Source:https://www.cbr.com/why-snape-killed-dumbledore-harry-potter/