Symbolism, Imagery, Allegory
For a story that takes place largely in the great outdoors, gateways, passages, doors and thresholds sure feature prominently in this poem. Barriers like these symbolize separation and transition—and they show up as both real physical doorways and as metaphorical passages.
Think about Enkidu transitioning from his natural, wild state, into his somewhat-civilized self. This transformation takes place through the passage of his experience with Shamhat—sex is often seen in cultures as a rite of passage. Then, Shamhat takes Enkidu to Uruk, but interestingly "Enkidu walked in front, and Shamhat after him" (2.80) as they went into Uruk, and therefore, through a gate that separated the natural, wild world from the tamed civilized world inside.
When Enkidu fails to convince Gilgamesh that messing with Humbaba isn't such a great idea, off they set straight through the gates of Uruk and from civilization back into nature. When they've killed Humbaba and cut down the largest trees in the cedar forest, what is it that they plan to do with their booty? Enkidu—a.k.a. nature boy—suggests a very civilized thing: "my friend, we have cut down a towering Cedar whose top scrapes the sky. Make from it a door" (5.327-328).
Yeah, we're fairly certain that this represents another transition.
One more thing: every time our characters come upon a threshold, they have to make a decision—will they move forward or go back?
In this way, the gates are also useful as literary devices to force characters into corners that they have to act their way out of. There is, for example, the Scorpion-Dudes at the gate to Mashu. They seem rather terrifying, and Gilgamesh is on a bit of a wild-goose-chase at this point. It would be much easier to turn around, especially with all the flack he is getting from said Scorpion-Man. But, he chooses to move forward, and that Scorpion-being seems to respect his decision.
Or, how about the locked door that Siduri slams in his face? Yes, Gilgamesh has gotten pretty far by this point, but we couldn't blame him if he had just had enough. He talks his way through the door, so to speak, and ends up getting the answer he is after—namely where to go to find Utanapishtim.
We also get a really spooky description of the underworld from Enkidu's dream. He says that at the entrance to the land of the dead, "upon the door and bolt lies dust" (7.183). This makes us wonder why there is a bolt on the door to the Underworld. Is this metaphorical? Or is there a literal bolt on the door to keep the living out? Or is it to keep the dead in?
Honestly, this is kind of freaking us out. Let's move on.