A corridor made of grey stone, ten feet wide and sixty feet long.
What's in there?
The only thing in there--the only thing in the classic, platonic dungeon is what you (the DM) put in there or what you (the players) brought with you.
You come to a town.
You come to the edge of a forest.
What's in there?
All kinds of stuff. The players are going to assume the forest will have trees, mushrooms, grass, lichens, maybe birds, hidden nests, dirt underneath the grass, rocks, and millions of other things that might tactically or thematically complicate the situation if they decide to get interested in them--and the same thing times a thousand in a city or a town. The adventurer in a town has access to all kinds of resources that you may or may not have thought of when writing the adventure.
This makes adventures based around the classic dungeon (and any interior space you use in a game which resembles a classic dungeon--a stripped-down Death Star, a Tron-like computery world, etc.) fundamentally unlike all other kinds of adventure.
A dungeon (at least a classic dungeon -- if you make a dungeon out of a spooky old house where people still live this may not be true) is just this big geometric platonic space with no features except those you decided would be fun. It's almost perfectly equivalent to starting with your little piece of graph paper and slowly drawing in rooms and monsters and traps and features.
Unoriginal Observations on Dungeons and Plot
In an adventure where the players are free to roam a civilized or uncivilized area, what, if anything, relegates the players to only those areas which the DM has put in effort ahead of time is plot.
As is true of many location-based adventures, a dungeon doesn't need a pre-designed plot because the only things in it are interesting things or at least things the DM assumes are interesting. As has also been pointed out before, limiting things in this way actually, paradoxically offers a great deal of freedom since no matter which way the players turn within the dungeon, there's something presumably game-worthy there.
Front-Loading the Artificiality
Basically by having/letting/suggesting that the PCs go down into a dungeon the DM is saying "Here are a number of ideas I'm willing to run with, you pick the ones that interest you and if you combine them or do something with them that I wasn't prepared for I totally accept the responsibility to keep going with it anyway because it was my idea in the first place that these things were interesting."
By having/letting/suggesting the PCs go around outside or in any kind of normal space the DM is often---whether he/she knows it or not--obliged to say in subtle ways "Here's where the adventure is, if you stray too far, I might get boring."
Now, naturally, at this point we'd talk about "winging it" which is all well and good and fine and often results in awesome adventures but often the players are as interested in getting to the well-thought-out stuff that the DM has got ready as the DM is and so they have to make a decision about whether they want to access whatever pre-thought-out creativity the DM (or the published scenario the DM is using) has in store or start a kind of totally improvised game that they know they will be constantly aware is going to be a totally improvised game.
The dungeon adventure is an agreement to go back and forth about certain things which are provided by the players in the form of their characters and what they are carrying and provided by the DM in the form of whatever he/she drew into the map. However, within those bounds both sides are pretty much agreeing to play ball all the way.
The not-dungeon adventure involves constant conscious attention from the DM to either keep the thing on track or to decide that she/he can deal with the thing not being on track and constant semi-conscious attention from the players to finding reasons to want to find the plot or trying to decide whether the improvisation they've pushed off into is as interesting as they thought it would be once they decided to ignore the plot.
Neither one of these is better than the other. I've got no problem letting my players run around outside.
I just think it's worth explictily pointing out that the physical space a game is supposed to be taking place in has profound effect on RPG design and the flow of the game at the table, and on what an RPG or a given day of RPGing is about. The transition from battlefield adventures to dungeon adventures essentially created RPGs as we known them--the transition from dungeon adventure to wilderness or town adventures introduced the whole idea of "plot" (in the sense of something pre-outlined rather than emergent) to RPGs.
Non-dungeon adventures generally require the DM start to employ a whole set of cinematic tricks which are now considered standard. It's possible to build a dungeon adventure completely around the idea of proper managment of resources over a sometimes-elided amount of time, in a more open scenario the DM has to constantly make desisions about whether to make the players role-play all the way through their taxi cab ride or just say "ok you're there" and whether to make them pay the rent or ignore the landlady and just go ahead and move them to the next scene that the DM thinks will be dramatic. This can have all kinds of unexpected effects, including tipping the PCs off to where the plot is when, in-game, they shouldn't know.
Dungeons are just as artificial as pre-fab plots and cinematic techniques, but the dungeon takes all the artificiality of a DM-constructed world and front-loads it--you accept that you're going to a place that's all stone and there's only a few things in it, and after that, it's often all seamless.
Dungeons And Information
Before it's been explored, the dungeon (or any interior space with a limited number of exits which you expect to keep the players busy for a decent chunk of game time) functions like a horror or investigative situation. What's there? Could be anything, we'll have to open the door and see. The DM has information, the players don't. Limited information is also the only way to run classic horror or detective stories if you want the players to feel anything like the way that the protagonist in these stories presumably feel.
It's exciting because Hey, look, the unexpected! It also puts all the power in the GM's hand.
However, once a dungeon room has been explored it switches genres and it now becomes a tactical element--or whatever the PCs want to use it as. It's empty and they're heavily armed, so basically the PCs now "own" that territory--in a way they don't necessarily "own" places and things they discover ouside the dungeon situation. For example, you find a room and there's a prisioner there--the players can decide to use this prisoner to test traps and stuff. (Or they can decide to ask him/her all about his or her in-laws--point is, s/he is now something they get to play with.)
Information is the key to the players being able to play any kind of tactical game (you are here I'm here, there's a wall here, the monster is over there, etc) and once a dungeon area has been explored the players have a fairly clear tactical canvas to play with in a way that just saying "ok, you're on a street here's an ogre" doesn't provide. The dungeon has a thing here and a trap there and a pit here, the dragon's in this room, that's the sum total of what you have to work with--go!
Dungeons and Problem-Solving
This points up another interesting thing about dungeons:
Tactical play and also "PCs decide what issues they want this story to be about"-type play can't usually happen at exactly the same instant as horror and mystery because tactical play and player-interest-driven play both rely on the players having lots of information and horror and mystery rely on the players not knowing what's just around the corner. However, the dungeon, by definition, must have two states--the explored and the unexplored--so the dungeon adventure has phases that allow both halves of the equation.
Outside the dungeon, this kind of plot structure also appears in a lot of places--for example, in certain noir movies and books. They start out with mysteries being revealed (in game terms--GM revealing to players stuff s/he has already written) and move on to the detective using those revealed elements--the mob boss's secretary, the photographer with the horrible secret--to foil the villain.
It also appears in adventure stories--the hero discovers a bizarre world that operates by bizarre laws and then uses those very laws and rules to defeat some big baddie occupying it.
The difference in game terms between the dungeon adventure and the outside adventures is that the dungeon requires very little real work on the part of the GM to make this interesting "use the rules of the weird place against that weird place" alchemy happen--all the GM has to do is provide enough details that do enough different kinds of things and any PC worth his/her salt will figure a way to recombine them in a way the GM hadn't thought of, whereas in an "outdoor" adventure there's always the posibility that the PCs will bring in some resource that is less interesting but equally effective.
Dungeons as Limited-Resource Scenarios
The reason is because the dungeon is, like the "ticking bomb" and the "bus can't go under 50mph" situation, a limited resource scenario. They make it hard for the PCs to just go to some setting-implied off-screen source of authority or weapons or money or doctors to solve problems.
If the DM wants Chinatown-like twists and doublebacks outside a limited-resource scenario she/he has to either accept that they might not happen or stick them in him/herself, whereas this kind of necessity-is-the-mother-of-invention reasoning is encoded into the basic premise of limited-resources scenarios. If the players are running around normally, this is harder to do without making the situation seem artificially restricted ("The gun store is closed. The glass is too thick to break. You see a police rover.")
In traditional art there are basically two kinds of sculpture: the kind where you take a chunk of stuff and carve things away until it's the shape you want it to be--"subtractive" sculpture--and the kind where you pile up material until it's shaped the way you want it to be shaped--"additive" sculpture.
In an "outside" adventure, the DM has to think of every single boring way the problems could be solved (police, doctors, friends, cars, trains, puzzle-solving experts) and cut them out of the situation ahead of time or right there in front of the players, like a subtractive scultpture. It can be hard because you have to subtract away every single thing that could make the situation boring. So you're sitting around thinking about boring. In a dungeon, it's additive--there's nothing but a blank piece of graph paper, to which you add only fun.
In other words, in a dungeon it's relatively easy to create a situation where the solution to the problems provided (or created) has to be interesting and unexpected. And that's neat.