Agreed that a lot of the problem is ranged versus melee. And there likely is an issue with the balance of hp vs martial damage output (I'm not an expert on the MM, so this could just be perception, and tbh, maybe a bit afield of the topic)
The oft-cited counterpoints to "range is too strong" are "melee gets attack of opportunity" and "you can grapple in melee"..which is cool.
Except that attack of opportunity doesn't trigger on spellcasting, just movement, and it does not impact spellcasting in any way unless it kills the caster. Grappling also..somehow.. does not impact spellcasting in any way. Neither does prone.. or restrained. So you can have that caster on the ground, halfway to an armbar, and they'd have an easier time teleporting to another plane of existence than stabbing you with their dagger. It's crazy.
Something should at least have the potential to make spellcasting more difficult. Maybe it's interrupts, maybe it's making more conditions applicable, maybe it's both, I don't know.
I just look at what happens when you take a caster prisoner. What do you have to do to secure them.
1. Take away their focus or materials pouch
2. Gag them
3. Blindfold them
4. Break or remove their hands (or invent a device to prevent somatic components because the game sure doesn't describe one)
5. Edit: Keep them from sleeping or otherwise resting.
And god help you if you capture a sorcerer or druid.
Like, maybe spellcasting doesn't have to be so reliable that you need to violate the Geneva Convention to prevent it?