Why do D&D, and other RPGs', players use 'dungeon' to mean the places they go to kill stuff?

I'm asking, because, dungeon usually means, or meant, a kind of prison, so I can't see how it evolved into "hunting ground", or however it's used in D&D.