Like Nesbit's The Railway Children, the story begins when a group of children move from London to the countryside of Kent. The five children – Cyril, Anthea, Robert, Jane, and their baby brother, known as the Lamb – are playing in a gravel pit when they uncover a rather grumpy, ugly, and occasionally malevolent Psammead or sand-fairy, who has the ability to grant wishes. He persuades the children to take one wish each day to be shared among them, with the caveat that the wishes will turn to stone at sunset. This, apparently, used to be the rule in the Stone Age, when all that children wished for was food, the bones of which then became fossils. The five children's first wish is to be "as beautiful as the day". The wish ends at sunset and its effects simply vanish, leading the Psammead to observe that some wishes are too fanciful to be changed to stone.
All the wishes go comically wrong. The children wish to be beautiful, but the servants do not recognise them and shut them out of the house. They wish to be rich, then find themselves with a gravel-pit full of gold spade guineas that no shop will accept as they are no longer in circulation, so they can't buy anything. A wish for wings seems to be going well, but at sunset the children find themselves stuck on top of a church bell tower with no way down, getting them into trouble with the gamekeeper who must take them home (though this wish has the happy side-effect of introducing the gamekeeper to the children's housemaid, who later marries him). Robert is bullied by the baker's boy, then wishes that he was bigger — whereupon he becomes eleven feet tall, and the other children show him at a travelling fair for coins. They also wish themselves into a castle, only to learn that it is being besieged, while a wish to meet real Red Indians ends with the children nearly being scalped.
The children's infant brother, the Lamb, is the victim of two wishes gone awry. In one, the children become annoyed with tending their brother and wish that someone else would want him, leading to a situation where everyone wants the baby, and the children must fend off kidnappers and Gypsies. Later, they wish that the baby would grow up faster, causing him to grow all at once into a selfish, smug young man who promptly leaves them all behind.
Finally, the children accidentally wish that they could give a wealthy woman's jewellery to their mother, causing all the jewellery to appear in their home. It seems that the gamekeeper, who is now their friend, will be blamed for robbery, and the children must beg the Psammead for a complex series of wishes to set things right. It agrees, on the condition that they will never ask It (meaning himself) for another wish. Only Anthea, who has grown close to It, makes sure that the final wish is that they will meet It again. The Psammead assures them that this wish will be granted.

Question: What happens when the children ask for a castle?
Answer: The castle gets attacked
Alternative answer: It is under siege.