what often gets overlooked is that there is a geographical component to all this.
Using
@Lanefan's example. There is a castle, there is a map of the castle, and on that map, there is a drawbridge with guards. There are also the other sides of the castle. Any one of these is fair game for the party to use to gain entrance to the inside of the castle. If the chosen side doesn't involve the one with the drawbridge and the guard, then that encounter is avoided, ignored, bypassed, etc.
All of this presumes you have a basic layout of the castle sketched with a rough idea of who is where when the PCs arrive at the location. Doesn't have to be as detailed as the below. But you need a sense of how the space is laid out and where the characters are within that space.