If you wanted to build a castle in medieval England, you needed permission from the king. They’re supposed to be for the defence of the realm, but sometimes you just want to fake out the neighbours.
There are around 460 surviving documents from the 12th to the 16th century CE that grant the “licence to crenellate” – the right to add fortifications to your buildings. (There’s a list of them in the second link below, although it was compiled by an amateur historian and so some are apparently of dubious provenance. There’s also a lot of castles without such supporting licences, so the question of whether a licence was legally necessary is open for debate.)
It makes sense that the monarch would want to control who had the right to fortify their castle, given the constant threat of internal trouble. The Peasants’ Revolt, the Cornish Uprisings, the Prayer Book Rebellion… you really wanted the people with the castles to be on your side.
Crenellations were also a status symbol, and there are examples of functionally useless battlements. So you get permission from the king (prestigious!) to build fortifications (prestigious!) – it doesn’t really matter if they would actually help you to defend your castle, or abbey, or town, or manor… as long as the neighbours are impressed. And if your neighbours are the “attack and raid” kind, phony battlements might intimidate them enough to keep you safe.