The first attestation of the word dungeon was in the 1400s, but there were a whole lot of variations in Middle English: it was also recorded as taking the forms dungeoun, dungoun, dungun, and dongoun, among others. All of these words either meant "tower", "keep", or had our modern definition of "dungeon". The reason all these incongruences existed was because dungeon is an inherently incongruent word. The truth is, it's an amalgam of the French word donjon, meaning "keep" (the main fortified tower of a castle), and the Old English word dung, meaning "prison". Together, they would make "castle prison" or "dungeon"- and this was a much-needed word at the time, so they were mashed together in every which way until we finally settled on a standard spelling. Dung is not the excretory dung you immediately think of; through Proto-Germanic, it comes from Proto-Indo-European deng, meaning "to cover". Donjon might have Frankish origins. If so, it would be from Proto-Germanic dungo, meaning "enclosed space", which ironically also hails from PIE deng, "to cover". So combining dung with donjon is just saying "cover cover", but that's what it is!
Hello! I'm Adam Aleksic. This year, I graduated from Harvard University with a degree in Government and Linguistics. There, I co-founded the Harvard Undergraduate Linguistics Society and wrote a thesis on Serbo-Croatian language policy, magna cum laude. In addition to etymology, I also really enjoy philosophy, trivia, vexillology, geography, board games, conlanging, art history, and law.