On the subject of fortifications being built in the wrong place, not strictly a castle but the walled citadel of Londonderry, host of the Great Siege of Derry, is despite its seemingly imposing location very poorly sited.Depends.
If the castle has a big garrison then yes. But a lot of places had only a castelan and a small defensive force. It’s comparatively easy to defend a castle with a small team and you can lay up supplies. Put a huge garrison in there for offensive purposes and the amount of time those supplies last reduces. I’m also wondering in that particular case where the water table is.
That castle might have been better sited nearer to the bridge or ford or whatever it was overlooking, perhaps with a small belvedere* on the hill to provide a longer view.
ISTR Napoleon was very good at identifying where fortifications were badly sited and simply bypassing them.
* As the other Bob says, remarkably similar to a modern OP or standing patrol in our modern parlance. One of my history lecturers found out I was a sapper and enjoyed comparing the evolution from curtain-walled castles to the ‘trace Italien’ and noting the similarities with modern defensive tactics: overlapping arcs of fire, covering obstacles, defence in depth, reverse slope, beaten zones, identifying the vital ground etc.
The job of building the walls was one of the world's first PFI contracts. King James couldn't afford it so in return for a profitable slice of the action from the Plantation of Ulster the guilds of London were franchised to build the walled city that would henceforth be called Londonderry.
And being a PFI it was done on the cheap and not to government specifications. First and foremost the problem was the location, the obvious site was on the hill on the southeast of the River Foyle, given that it would be from the south or east that any aid from England would come. Not only that but the hill on the east is higher than the "island" of Derry where the walls were actually built. But the engineers looked at the island site, decided a river acted as a good moat and there were the ruins of an abbey that could serve as basic foundations.
And so it was during the siege that far from the Foyle acting as a defensive moat, the besiegers, having the benefit of controlling the southern and eastern access points and thus cutting the city off from aid by land, laid a boom across the river and effectively isolated the garrison completely. They then set their cannon up on the eastern hills and on the hills where the Creggan estate now sits and easily lobbed shells in on top of the besieged.
The Siege of Derry ended well for the garrison but it was a damned close run thing and in all the joyful celebrations few asked how it was that the city's walls were built in such a stupid location.