I usually build my maps so that the melee fighter/barbarian have a possibility to be useful. And I will sacrifice a little immersion / realism to achieve this if needed, but that is often not necessary. Mansions or lairs often have a few entrances and a system of hallways and rooms that give plenty of dead ends, narrow doorways and other choke points. If the party acts like a good team they shouldn't get ambushed from the back.
Also, I will sometimes deliberately add some low-Int monsters to a fight in open field which the high-Int bad guys deliberately use as cannon fodder, and have those rush at the melee guys.
If the party will always be outflanked and outsmarted then strategic positioning is not much fun, and my PCs would all start to complain: The squishy Sorc for being attacked all the time and making (and failing) too many concentration checks, the fighter and barbarian for not
being attacked enough, etc.
But of course I keep them sharp by not being nice all the time