The dungeons might have been in use as dungeons when Hogwarts first opened.
While it does seem odd that a school is built with dungeons, The dungeons may have been used to lock away dangerous things, like magical creatures, or to keep certain items guarded. We know of at least one instance where a magical item, the Philosopher's Stone, was kept in the dungeons at Hogwarts. Historically, the dungeons might have been used in this way as well. It was considered safe enough during Harry's time at Hogwarts to guard the Stone in the dungeons while Hogwarts continued to function as a school, so it's possible that the Founders had the same sort of thing in mind when they chose to build dungeons. Dumbledore, who was the one who hid the Stone and would know, mentions that the room with the Mirror of Erised where Harry fought with Quirrell was in the dungeons.
“What happened down in the dungeons between you and Professor Quirrell is a complete secret, so, naturally, the whole school knows.”
- Harry Potter and the Philosopher's Stone, Chapter 17 (The Man with Two Faces)
The dungeons can also be used to safeguard less remarkable objects, like when Harry's Firebolt is confiscated.
“Filch fitted a new door and removed Harry’s Firebolt to the dungeons where, it was rumoured, Umbridge had set an armed security troll to guard it. However, her troubles were far from over.”
- Harry Potter and the Order of the Phoenix, Chapter 30 (Grawp)
This is another example that proves Harry's Firebolt is indeed being guarded in the dungeons.
“Liar.’ She shook his head again. ‘Your Firebolt is under strict guard in the dungeons, as you very well know, Potter. You had your head in my fire. With whom have you been communicating?”
- Harry Potter and the Order of the Phoenix, Chapter 32 (Out of the Fire)
It's possible that the dungeons were actually used to punish students in times gone by at Hogwarts.
“He wouldn’t believe they were lost, was sure they were trying to break into it on purpose and was threatening to lock them in the dungeons when they were rescued by Professor Quirrell, who was passing.”
- Harry Potter and the Philosopher's Stone, Chapter 8 (The Potions Master)
Filch also refers to the old punishments having died out, one of which was the students being hung from the ceiling by their wrists. It's less likely that he's simply exaggerating in this case, as he probably doesn't know that Harry can hear him, and he has no reason to make punishments sound worse for Snape, who would know what common Hogwarts punishments are anyway.
“Follow me,’ said Filch, lighting a lamp and leading them outside. ‘I bet you’ll think twice about breaking a school rule again, won’t you, eh?’ he continued, leering at them. ‘Oh yes … hard work and pain are the best teachers if you ask me … It’s just a pity they let the old punishments die out … hang you by your wrists from the ceiling for a few days, I’ve got the chains still in my office, keep ’em well oiled in case they’re ever needed … Right, off we go, and don’t think of running off, now, it’ll be worse for you if you do.”
- Harry Potter and the Philosopher's Stone, Chapter 15 (The Forbidden Forest)