In the sixth book Harry summons Kreacher (and Dobby comes too) when he's in the hospital wing after he was hit by the bludger. Crack and then they just were there. Is this just a mistake in the book?
Yes, house-elves are able to Apparate inside of Hogwarts. In Chamber of Secrets Dobby Apparates in and out of the hospital wing when Harry is regrowing the bones in his arm.
‘Dobby must go!’ breathed the elf, terrified; there was a loud crack, and Harry’s fist was suddenly clenched on thin air. He slumped back into bed, his eyes on the dark doorway to the hospital wing as the footsteps drew nearer.
Chamber of Secrets - Page 134 - British Hardcover
In Half-Blood Prince, Dobby and Kreacher are both shown Apparating in the chapter where Harry asks Kreacher to tail Draco Malfoy. House-elf magic is different than Wizarding magic. I'd give you another example of a house-elf being able to Apparate under conditions that a witch or wizard cannot, but I know you have not read Deathly Hallows yet.
Quietly, tentatively, Harry spoke into the darkness.
There was a very loud crack and the sounds of scuffling and squeaks filled the silent room. Ron awoke with a yelp.
‘What’s going –?’
Harry pointed his wand hastily at the door of Madam Pomfrey’s office and muttered 'Muffliato!’ so that she would not come running. Then he scrambled to the end of his bed for a better look at what was going on.
Two house-elves were rolling around on the floor in the middle of the dormitory [...]
Half-Blood Prince - Pages 392-393 - British Hardcover
(REQUESTED) SPOILERS FROM DEATHLY HALLOWS:
In Deathly Hallows, Kreacher relates a tale how Voldemort required a house-elf for a task, and Regulus Black took Kreacher to Voldemort to complete it. Regulus ordered Kreacher to come back to Grimmauld Place after he completed Voldemort's task. Basically, Voldemort had Kreacher drink the potion in the basin in the sea cave where the Slytherin locket Horcrux was; Kreacher drank the potion; Voldemort dropped the locket Horcrux into the basin and refilled it with potion, and then left Kreacher to die in the cave with the lake full of Inferi. The potion made Kreacher so thirsty that he drank from the lake and was dragged underwater by the Inferi. However, he managed to Dispparate from underwater inside the sea cave back to Grimmauld Place.
‘How did you get away?’ Harry asked, and he was not surprised to hear himself whispering.
Kreacher raised his ugly head and looked at Harry with his great, bloodshot eyes. ‘Master Regulus told Kreacher to come back,’ he said.
‘I know – but how did you escape the Inferi?’
Kreacher did not seem to understand. ‘Master Regulus told Kreacher to come back,’ he repeated.
‘I know, but –’
‘Well, it’s obvious, isn’t it, Harry?’ said Ron. ‘He Disapparated!’
‘But ... you couldn’t Apparate in and out of that cave,’ said Harry, ‘otherwise Dumbledore –’
‘Elf magic isn’t like wizard’s magic, is it?’ said Ron. ‘I mean, they can Apparate and Disapparate in and out of Hogwarts when we can’t.’
Deathly Hallows - Pages 160-161 - British Hardcover
JKR answered a similar question, when asked:
Rorujin: How is Dobby able to apparate inside Hogwarts if no one else can?
JK Rowling: He's a house-elf, they've got powers wizards haven't got (but wizards have also got powers that house-elves haven't).
which clearly indicates that the nature of house elven magic differs from that of a wizard's and is often underestimated, after all, who would fear a house elf?
Besides, they might be using such magic to get their duties done quickly in the castle!
Yes, JKR allowed for elves to apparate in and out of Hogwarts. Though, this is one of the weaknesses in the Harry Potter series since Hogwarts had enchantments to protect it from disallowing unwanted guests to enter the castle, for instance. If someone really wanted to enter the castle, one could simply have a house-elf, under orders, apparate the person inside Hogwarts.