I've never understood how this works.
The answer is, in a sense, an obvious one: that the initial area that the fishing community settled along the river Amstel in the early 1200s was very close to sea level (but above it). There was a significant saltwater inlet that had a tendency to flood, so the initial settlement included a dam of sorts--doors under an early bridge--to prevent inundantion. It was evidently not always very successful. But the position on the Amstel was excellent for fishing boats and later for commerce, so it was worthwhile to continue defensive construction. As the city grew, it took in some areas that were even more prone to inundation, and the defensive works (along with the rings of canals, added I think in the 16th century) developed in tandem with that sprawl. The result is that on average the massively expanded Amsterdam today is a little less than 2m below sea level. It's hard for those reasons (and, well, because of the presence of the city) to do really good archaeology within it, but fortunately we have a lot of historic maps showing the development from at least the 1500s and some speculating on earlier patterns. Those defenses did not stop the city from suffering periodic floods anyway like Sintpietersvloed or St. Peter's Flood of 1651, but those do explain why the elaboration of the dam system was taken so very seriously at such an early date. [edit: I'm not sure whether Amsterdam itself was the site of terpen, which other commenters point to below--I've never heard of that, but one might well suspect an enterprising farmer or fisher would try to gain a half meter for the house plot if they could!]
TL,DR: Fishermen, who aren't too worried about the occasional wet feet, settled close to a good harbor and good fishing; it became a commercial port and developed the dam & canal system as it grew in area.
The history of the Dutch polder system
Added: once you pump the water out, the land sinks, so you end up a lot lower than when you started. It wasn't this low at the beginning.
So does the name "Amsterdam" literally mean "amstel dam?"
It is a bit out of scope, so forgive me but many people ask the same thing about New Orleans (e.g. "why the hell would you %$#! live below sea level?!"). It turns out that the areas originally settled were above sea level. Areas that include the French Quarter, the Garden District, and Carrolton were all built on natural levees.
In 1893, the Sewerage and Water Board was, in part, created to develop pumping stations. Throughout the early 20th century, previously unusable swampland was drained and sold for houses (the blue areas). Unfortunately (and this will be unsourced, but forgive me), much of this land, especially the broad swaths of New Orleans East were sold to upwardly mobile black families post-war. Lakeview was also a later development as well, but mostly white.
When the levees failed, these areas were flooded and a disproportionate number of black families were displaced. The expensive Garden District (the "isle of denial") and Vieux Carre (founded earlier and mostly white) did not experience nearly the devastation that the "inner city" did. An big exception to this was Lakeview, in the north west portion of the city and founded much later, which is a mostly white neighborhood that was under 10-15 feet of water.
There's a geology bit too. Cities that get founded on river deltas tend to sink. River deltas are dynamic. The continuously bring debris and sediment into the delta. This is a huge pile of soft debris and sand. So after depositing more...it sinks more...but but...more stuff keeps getting added naturally by flood cycles. Cities on deltas channel the rivers to take away all the new sediment. So no new sediment is added.
So now the city is on a piece of land that will continue to sink naturally. The dykes grow higher in response.
The sinking due to soft heavy mush below was not something people of those times were aware of. New Orleans same deal...bigger river.
There is not bedrock nearby under these cities. They sit on dynamic relatively mushy ground that continues to settle.
edit: ask /r/geology I bet there's folk there that really know the whole deal on these specific cites...
People have been finding ways to avoid the water for centuries. Anyone settling in the area up until about 1000AD probably built their farmhouses on man-made hills called terps. As technology progressed, dikes eventually connected these terps. Once these dikes became more intricate and integrated in the 11th century they created polders (simply land reclaimed from the sea). By 1100AD these farmers were already well aware of the risks the water posed. Communities then started electing a local representative whose sole job was to watch water levels and form protection from floods. By the 13th century the windmill would have been discovered and implemented into some areas. They could be used to drain water out of below sea level areas. This, in turn, improved the quality and frequency of polders, thus resulting in more available land.
This is some of the early history of settlers in the Netherlands dealing with sea level. Here is a bit more information on polders in the Netherlands, but for futher information on anything I mentioned (and a lot more) I recommend this book by Roegholt on the history of Amsterdam. Sorry if this does not deal specifically with how Amsterdam was founded, I addressed it from the perspective of how early settlers in the region dealt with living below sea level.
I don't mean to hijack, but what about Venice? When I went, I read a story that said, "the Venetians TOOK the city from the sea." I thought that was epic, but how did they do it? I just don't get it.
On a related note, if they are below sea level and near salt water, where do they get fresh water? Surely the water flowing from the rivers is brackish so close to the sea.