Most Wizarding dwellings are shielded against Apparation.
“Professor, why couldn’t we just Apparate directly into your old colleague’s house?”
“Because it would be quite as rude as kicking down the front door,” said Dumbledore. “Courtesy dictates that we offer fellow wizards the opportunity of denying us entry. In any case, most Wizarding dwellings are magically protected from unwanted Apparators.
(Harry Potter and the Half-Blood Prince - Chapter 4)
Yet everyone in the Wizarding world apparently assumes that Hogwarts would be different. Why is this?
All around them, people were asking one another the same question: “How did he get in?”
“Maybe he knows how to Apparate,” said a Ravenclaw a few feet away. “Just appear out of thin air, you know.”
(Harry Potter and the Prisoner of Azkaban - Chapter 9)“Harry!” squealed Hermione. “What are you doing here? How — how did you — ?”
“Wow!” said Ron, looking very impressed, “you’ve learned to Apparate!”
(Harry Potter and the Prisoner of Azkaban - Chapter 10)“He must have Disapparated, Severus. We should have left somebody in the room with him. When this gets out —”
(Harry Potter and the Prisoner of Azkaban - Chapter 22)“A Portkey?” Ron suggested. “Or they could Apparate — maybe you’re allowed to do it under seventeen wherever they come from?”
“You can’t Apparate inside the Hogwarts grounds, how often do I have to tell you?” said Hermione impatiently.
(Harry Potter and the Goblet of Fire - Chapter 15)“I don’t think so,” said Harry, shaking his head. “He seemed really weak — I don’t reckon he was up to Disapparating or anything.”
“You can’t Disapparate on the Hogwarts grounds, haven’t I told you enough times?” said Hermione.
(Harry Potter and the Goblet of Fire - Chapter 29)“So he did Disapparate?” said Ron.
“You can’t Disapparate on the grounds, Ron!” said Hermione.
(Harry Potter and the Goblet of Fire - Chapter 29)“One day,” said Hermione, sounding thoroughly exasperated, “you’ll read Hogwarts, A History, and perhaps that will remind you that you can’t Apparate or Disapparate inside Hogwarts. Even Voldemort couldn’t just make you fly out of your dormitory, Harry.”
(Harry Potter and the Order of the Phoenix - Chapter 23)