Can anyone tell me this its very frustrating
You walk towards the gate and the NPC will open it automatically.
Yeah apparently I was trying t get into the wrong compound sorry
I can see why that would be frustrating.
Some NPCs are scripted to handle certain gates, for instance, the Byn has a NPC like this in its southern compound. You can either walk in the direction of the gate to get right through, or, open <object> <direction>. The latter will prompt the NPC to use their key and open the gate wide without you going through. This has use in some situations.
If there is no NPC controlling the <object> the latter technique will work as well, but you'll open it.
If an NPC reacts by stepping in front of you and <some message of denial> it means you're not of sufficient rank/in the clan responsible for monitoring traffic there, which is the tip off its the wrong gate.