I define a hazard as an aspect of the environment or terrain that poses a threat to the party. Examples might include avalanches, cave-ins, boiling geysers and rooms full of poison gas.
I've got some questions around the best way to use hazards. Specifically:
* What is the "in game" purpose of hazards?
* How do you make hazards fun for the players?
* How does the use of dungeon hazards differ from wilderness hazards?
* What are 1 or 2 good examples of hazard encounters?
First, I'd like to point to 4e as an amazing source of examples of hazards, including cool mechanics for dealing with them. They're in a lot (most?) of 4e adventures, and work like traps, except that they aren't intentionally set to hurt people... they just do.
So to answer your questions:
1. The in game purpose of hazards (at least, to me) is twofold: first is to make encounters more interesting by adding an additional component to them. Second is to establish that the environment is a thing that isn't always safe for you, which is part of the worldbuilding element of D&D.
2. I find that most of my players enjoy hazard encounter/situations. They like that it's a challenge that they can't just stab (well, usually). I find that few players want the same situation to happen over and over again; most enjoy it when there's a catch or a trick to things. When they have to think their way through something instead of just rolling to hit and damage.
3. The nature of the hazards are different. Dungeon hazards might include green slime and cave ins, which you can't have under an open sky in sunlight. Conversely, outdoor hazards might include a lightning storm or wildfire that the pcs have to seek shelter from, which you can't have underground (usually, easily).
4. Some examples. Okay. Can't limit myself to one or two, sorry. Some of these could overlap between categories, too.
Dungeon hazards include green slime, yellow mold, brown mold, ear seekers, cave-ins, unsafe floors, water dangers (including flooding and areas you have to navigate through underwater), razor-sharp rocks, phycomids, poisonous or noxious gasses, acid or lava pools, giant spider webs, boiling-hot geysers of mud that may erupt at any moment, areas of extreme heat or cold, etc.
Wilderness hazards include finding food or water that is tainted or poisoned, lightning storms, wildfires, avalanches, flash floods, disease exposures (hi jungle fever), earthquakes, volcanoes, poison oak or ivy, magical plants that put you to sleep for a thousand years, slippery ascents alongside a waterfall, lack of food and water, spoilage of supplies, sandstorms, acid rain, the divine wrath of a deity that brings curses down on a whole landscape, etc.
Urban hazards include accidentally stepping on a spike, dagger, shard of broken glass, etc that works its way through your boot, getting your pockets picked (though this is arguable- you could easily call this a creature encounter instead), plague exposure, famine, fires in the city (arguably the very worst thing for a city in pre-modern times), a miasma caused by all the smoke from all the fires, alchemical run off (various potential effects), pot holes that make your wagon throw a wheel or your horse break its ankle, getting chamber pots thrown on you from a window above the street (more disease), etc.