The word dungeon derives from the French donjon for a central tower (or keep) in a castle, and the latter word is still used in this sense in English. It is possibly derived from the Latin dominus "lord, master". Dungeon later came to be (mis)used as the name for a cell or oubliette, often situated in the lower floor or basement of a keep.
I believe that Dungeons & Dragons may be the first instance of the use of dungeon to mean larger caverns or catacombs, though it should be noted that most of the early adventures took place in the basements of towers of castles or in ancient tombs rather than actual caverns, making the use of the word less of a misnomer. I imagine that the way way the word alliterates with dragons is a factor; Crypts & Dragons just doesn't have the same ring to it.
As for the origin of "dungeons" as a venue for fantasy adventure, I believe that The Hobbit (1937) was the main inspiration for Gary Gygax, who adored the book, but didn't care much for The Lord of the Rings. In The Hobbit, Bilbo has a lengthy underground adventure in the Misty Mountains where he runs into Gollum, then beneath the castle of the wood elves, and again in The Lonely Mountain, where he runs into Smaug - we hence have both a dungeon and a dragon.
As Lucas Backmann wrote in a comment above, Edgar Rice Burroughs may also be an influence, and his heroes do tend to be trapped underground, but their main adventure seems to be to find a way to escape rather than fighting monsters or finding treasure. In fact, The Hobbit has all the main elements of Dungeons & Dragons, also including the four classic D&D races, orcs, a thief (of sorts), wizards, magic swords that glow in the presence of enemies, mithril armor and a Ring of Invisibility.
Another possible influence is Robert E. Howard's stories of Conan and King Kull, who also have their share of underground adventures.