Rivendell was located in a hidden valley; and, while it is obvious that being hidden was a helpful defence - I find it very difficult to imagine how a valley was defended when the enemy had succeeded in locating and attacking Rivendell.
Rivendell was twice besieged by Sauron - once in the second and again (by the Witch King of Angmar) in the third age (there is a description in the History of Middle Earth of the near starvation during one of these sieges).
But I cannot understand how - at least in a material military sense - a valley could be defended; since castles are always placed upon raised ground. To be located in a valley allows the enemy to approach unmolested, and gives height advantage in hand to hand fighting - while allowing the enemy to rain down projectiles from the valley sides. Furthermore, it seems that the house of Elrond itself was not fortified - at least, this is never mentioned nor depicted by Tolkien in his drawings.
However, since Rivendell did indeed withstand two sieges, despite being in a very disadvantageous location; I think we must look elsewhere for an explanation.
My best guess is that it was defended by High Elf magic, in some way analogous to the Girdle of Melian - which was an encircling, magical barrier cast by Melian, wife of Thingol Greycloak - around the Sindarin elf kingdom of Doriath. This (usually) caused the unauthorized to become bewildered and lost - to die of starvation.
It may be that this was how Rivendell was 'hidden' from hostile eyes - because otherwise Saurons winged servants (such as crows) could surely spot any large valley - no matter how flat the surrounding landscape.
Perhaps during the sieges of Rivendell, the forces of Sauron could not find the valley; or (at least, not without the physical presence of Sauron himself) could not get through it and into Rivendell. Perhaps their plan involved starving the elves towards a point where the barrier would weaken or break?