How could Harry and Ron so easily fly Mr. Weasley's car (the magically enhanced Ford Anglia) to Hogwarts, when many times in the book it is mentioned that Hogwarts is protected by various spells, such that even Dumbledore had to revert all the security spells in Harry Potter and the Half-Blood Prince so that Harry and Dumbledore could enter Hogwarts on a broomstick?
The evidence points that there were no restrictions or preventative spells keeping people from flying into and out of Hogwarts till year 6.
‘There are all sorts of enchantments on it, to stop people entering by stealth. You can’t just Apparate in here.And I’d like to see the disguise that could fool those Dementors. They’re guarding every single entrance to the grounds. They’d have seen him fly in, too. And Filch knows all the secret passages, they’ll have them covered ...’
Here we have Hermione spelling it out fairly clear that the enchantments do NOT prevent people from flying in.
In year 1 Charlie Weasley’s friends fly in and out to take out Norbert.
The steep spiral staircase up to the top of the tower seemed the easiest thing in the world after that....About ten minutes later, four broomsticks came swooping down out of the darkness. They showed Harry and Hermione the harness they’d rigged up, so they could suspend Norbert between them. They all helped buckle Norbert safely into it and then Harry and Hermione shook hands with the others and thanked them very much.
Year 2 we have the flying car fly into the grounds.
Year 3 we have Sirius Black flying out of Hogwarts on Buckbeak.
He squeezed Buckbeak’s sides with his heels. Harry and Hermione jumped back as the enormous wings rose once more ... the Hippogriff took off into the air ... he and his rider became smaller and smaller as Harry gazed after them ... then a cloud drifted across the moon ... they were gone.
Year 4 the Beauxbatons carriage flew in.
Something large, much larger than a broomstick – or indeed, a hundred broomsticks – was hurtling across the deep blue sky towards the castle, growing larger all the time... they saw a gigantic, powder-blue, horse-drawn carriage, the size of a large house, soaring towards them, pulled through the air by a dozen winged horses, all palominos, and each the size of an elephant.
Year 5 Harry and crew fly Thestrals out of the grounds, and Fred and George fly out on broom.
Harry did not think he had ever moved so fast: the Thestral streaked over the castle, its wide wings hardly beating; the cooling air was slapping Harry’s face; eyes screwed up against the rushing wind, he looked round and saw his five fellows soaring along behind him, each of them bent as low as possible into the neck of their Thestral to protect themselves from his slipstream.
And Peeves, who Harry had never seen take an order from a student before, swept his belled hat from his head and sprang to a salute as Fred and George wheeled about to tumultuous applause from the students below and sped out of the open front doors into the glorious sunset.
Finally, in year 6 we see the protections are added.
“Alohomora!” he said confidently, pointing his wand at the padlock, but nothing happened.
“That won’t work on these,” said Tonks. “Dumbledore bewitched them himself.” Harry looked around.
“I could climb a wall,” he suggested.
“No, you couldn’t,” said Tonks flatly. “Anti-intruder jinxes on all of them. Security’s been tightened a hundredfold this summer.”
Dumbledore muttering in some strange language again. He thought he understood why as he felt his broom shudder for a moment when they flew over the boundary wall into the grounds: Dumbledore was undoing the enchantments he himself had set around the castle, so that they could enter at speed.
During Harry Potter and the Half-Blood Prince the country was in the middle of a civil war. Any protections available would have been in place at full strength.
On the other hand during Harry Potter and the Chamber of Secrets story the country was at peace. Also, when Harry and Ron arrived in the flying Ford Anglia they were both individuals authorized and expected to be entering the school grounds on that day. It seems logical that the wards would allow them entry.