Losing is fun!
Either way, it keeps you busy.
There is no internal end point or single goal or final Easter egg or "You Win!" announcement in Dwarf Fortress. Therefore, eventually, almost every fortress will fall. The only ones that don't tend to be very conservative and very boring - and what fun is that? Therefore, DF = losing, losing = fun, DF = losing = fun, and that's okay! It's a game philosophy, so embrace it, own it, and have fun with it!
Most new players will lose their first few forts earlier than later;
if when you lose a fortress, don't feel like you don't understand the game. Dwarf Fortress has a steep learning curve, and part of the process (and fun!) is discovering things for yourself. However, this Wiki serves as an excellent place to speed up the learning process.
Various common things can cause the death of a fortress. Let's examine some together...
 Local Wildlife
Goblins aren't the only creatures that want you dead. The obvious threats aside, some creatures with benign names or descriptions can be surprisingly deadly. Be it unicorns, hippos, rhesus macaques, or (gulp) carp, a sudden wildlife attack can quickly cripple or destroy an unprepared fortress. Before you unpause the a new game for the first time, hit nits, and scroll down to see what's sharing your map. Learn to do this regularly - new creatures will frequently migrate onto your map and then off again to be replaced by others.
Consider arming up and thinning out any predictable threats, which can also help avoid the next problem...
 No Food
A serious danger, generally in the more inhospitable climates, is the loss of your dwarves due to starvation. As dwarves begin to starve, they will become Hungry, then Starving. This will cause them first to slow down all work, and then to become very unhappy. When they die, their friends will become upset and will become even more unhappy, potentially causing the remainder of your fortress to break out in a terminal hissy fit.
Don't forget your alternative sources of food. If your farms aren't doing the job and a trade caravan is months away, try butchering your domestic animals, gathering plants, or resorting to hunting of local wildlife.
 No Booze
Equally as bad is no alcohol, which dwarves require to be happy and productive. Some alcohol can be acquired from caravans, but not enough for an entire fort until the next caravan arrives. You must farm plants to then brew those in a still with an empty barrel - it's just part of being a dwarf.
 No water
This can be one of the biggest problems with a fortress that has no brook, river, or other source of fresh water. Any available standing water must be rapidly gathered from stagnant pools and stored into an indoor basin or water tower, with sufficient depth before it evaporates. If this fails, all of the water on the map can quickly evaporate and your dwarves will be left without any water.
Healthy dwarves will not die of thirst as long as they have alcohol, which in the current version can be brewed without the use of water. However, injured dwarves must be given water, not alcohol, or they will die of dehydration.
Rain will refill stagnant pools of water slowly. In a hot climate, this may evaporate almost immediately. What's more, if the map is in a dry climate, such as a desert (hot or cold), then there can be long periods of time with no water anywhere - in extreme cases, none ever. Snow will not refill pools, so you can also have a lack of water in very cold climates. Also, if weather has been turned off in the init.txt file then there will be no rain and no water will accumulate, though it may be there at the beginning of the game.
 Flooding accidents (aka "too much water")
The opposite side of the dehydration spectrum is having too much water. Remember that water can flow in 10 directions (the 8 horizontal ones as well as up and down, to the level of its source.)
If your fortress is beginning to flood from sourced water, abandon all of the levels the water can reach immediately—drafting dwarves into the military and stationing them onto the surface if need be. You will never be able to recover those areas unless you can manage to pump out the water faster than it floods in, which can take over a year or two of game time to establish a functioning automated pump system. Generally, a flooding accident spells doom for your fortress.
Sometimes a fortress is flooded with magma. This is even more fun, and even harder to recover from. Any shut door will stop magma, it doesn't rise as aggressively (via pressure) as water, and magma can be pumped out with the right equipment. Read up on it. Good luck.
 Inability to mine (aka "no picks")
Simply put, you need picks to mine ore, which is then smelted to make metal for items like more picks. If you are careless (or ignorant) of how to dig safely, and your miners create a collapse or flood and their equipment gets lost/destroyed/unrecoverable, and you have no materials to make more picks, you will be at a severe handicap until the problem is solved. Any dwarf can be given the mining labour, but without a pick they can do nothing. There is no way to get new metals or stone for any purpose nor any way to dig new rooms/tunnels unless you have picks.
If you have ore or bars to create a weapons-grade metal, and a forge (and smelter if you need one), you can create new picks and continue. You can also get lucky with a dwarven caravan - elves and humans don't (ever?) offer picks. If the first dwarven caravan doesn't bring any, you can try to keep your fortress running long enough to request additional picks from your Outpost Liaison, who will arrive with the next dwarven trade caravan in a year. Or you can abandon and try again.
Averting this fate is simple: stockpile at least one additional pick at the first possible opportunity, or some of the raw material to make more, and keep them away from current digging operations.
See also: Making your own weapons
 General Unhappiness
If there is little in a fortress to give your dwarves happy thoughts and enough to give them unhappy thoughts, then your dwarves will start to throw tantrums, grow melancholy, and/or cause general chaos. In extreme (but sadly not "rare") examples, this can lead to a tantrum spiral and the loss of the entire fortress. Unhappiness is more likely to occur if your fortress is suffering other kinds of downfall, so try to keep all the bases covered.
After the first year or so, the goblins will come; first with about half a dozen naked wrestlers, then a dozen armed goons. Then they come again with about two dozen, and master archers. Occasionally, they are accompanied by trolls or ride beak dogs. You can't see them until they attack, so it is too late when you detect them to start doing something about it. Soon enough your traps are all sprung, and your dwarves are dead. Without some sort of defenses, such as a moat or traps, a horde of goblins on your doorstep can be deadly.
The goblins may not be your only enemy; remember that time you "accidentally" pulled the lever and flung that poor elf trader into the sky? Well turns out they got pretty annoyed, prepare for an elven war! It may only take a simple accident (like killing a preachy hippy elf) to start a war you can't possibly win. War is especially difficult to overcome when your fort is taking its first steps, but it is easy to prevent unless you really hate elves- or humans (but then you have other serious problems, dude). The usual goblin skirmishes and sieges do not even count as war - a proper war will be signaled on the embark screen and will be denoted in-game on the ivilization screen. (NOTE: You cannot be at war with your own race, so no epic dwarf showdowns.)
Sieges can be quite devastating to a fortress, but unlike most of the other ways of losing they are unlikely to occur early on, even if you do something stupid to piss off another civilization. Goblin sieges, for example, will only occur if you have 80 or more dwarves.
Should hosts of goblins besiege your gates and drive your peasantry inside, trolls beat down your doors and force you to seal off from the outside world, you may have already lost the game. Even if you have built an utterly impenetrable fortress with drawbridges and moats, siegers may stick around for a long time. Although a dwarven fortress can be made self-contained, with crops, metal and fuel readily available, underground wood source and your own livestock, a fortress may not sustain such a state indefinitely. For example, trade with the outside world has now been shut off, leaving you only what ores are on your map for the production of mandate goods. In the (very) long run even those will run out. This can result in a breakdown of social order if you do not prevent your Hammerer from killing or maiming your dwarves. Shell, bone, and leather commonly acquired by hunting and fishing need to be supplied by previously established livestock, an underground river and a sealed off channel from a murky pool or river. If these resources are no longer available to your workers, moody craftsdwarves will be driven into suicide or worse. Rotten vermin corpses begin to heap in your food supply, forcing you to dump these into inside refuse piles, generating miasma. One small miscalculation of your fuel reserves may leave you without coke to refine further coal, and without a supply of timber for your wood burning furnace this can end your vital weapons and armor production for a future counterattack. Unless an interior watersupply was established your wounded will die of dehydration.
With all these critical industries unproductive, dwarves dying, and friends mourning over the rotting heaps of slain loved ones, it's important to remember your dwarves have nothing to do but throw funeral receptions, grief counseling sessions, and the occasional keg stand. This means they've all become one big happy family of friends, manically depressed from the loss of any dwarf.
In short, the attacking army can simply wait until your dwarves emo themselves to death.
 Volcanic Death
Volcanoes do not erupt in version 40d, but are planned to do so at some point in the future (see Toady's response on the plans for Volcanoes here.) If magma pours from a volcano on your map, it is a bug and should be reported as such (though bugs are their own category of Fun.)
It is still possible to die from magma without bugs if you're trying to pull a Boatmurdered (i.e. flood the world with magma) or if you just want to roast those sieges sitting at your front door.