You're seeing one of the classic military ideas play out in your game — control of chokepoints. As many other people have pointed out, the advantage to controlling a chokepoint is that you can step back and force the enemy to push a narrow front of combatants against a broad base of defenders — so the person coming through the door is taking the most attacks.
Obviously, though players (somewhat) tend to be better disciplined than most people were in real life — players are not going to rush their characters through pushed on by adrenaline and machoism to face multiple attackers, but probably back off and attempt to attack at range. This is assuming NPCs with little planning or expectation to be fighting indoors — but if they are? The game changes drastically.
Buying Time
NPCs fighting defensively are often buying time until reinforcements can be summoned. This means they can focus on defense, since their goal is to stay alive and keep the enemy occupied until help arrives. This may also involve using some kind of push or shove action to push the enemy back and slam the door shut. Or, maybe tripping and knocking down the enemy so their allies have to step over them to get to you.
Alternatively, they may choose to retreat from the door, throw down caltrops, or knock over an urn of burning coals, etc. and retreat to the next defensible doorway or position. Knocking over furniture to block the path might also be a worthwhile choice.
If they've already notified the reinforcements, there may be a hidden ambush in the next room, or a lot of crossbow wielders all basically waiting to see what non-ally tries to get through the door.
Or, if there's a way for the reinforcements to loop around the party's rear, they may do that, instead.
Pulling out the Wounded
You have a line of combatants. Behind them, are their replacements. When someone is wounded, an ally pulls them back and shoves them to the rear, while another person steps up and fills the gap. This requires well trained troops used to formation fighting, although, by usual D&D mythos, hobgoblins are pretty organized fighting units, so this would make sense.
Although in D&D there's no real wounding or ability loss until one hits 0 hitpoints, it might be worth remembering any surviving hobgoblins can report back intel on the group, and they can plan better — who are the spell casters? What kind of fighting styles does the group use? This is even more important when you realize that the enemies will start bringing countermeasures in tactics and defensive tools to help deal with the enemy.
Indoor Weapons
Spears are not universally good indoors, but they can make controlling a hallway or doorway a very viable option. In real life, you can get many spears lined up, two or even more lines of troops aimed in a small space. If you're using the grid rules in 5E that is more limited than real life options, but still doable.
Darts and crossbows are pretty great indoor weapons for ranged options. Short bows might also work too.
Defensive Architecture
A lot of castles throughout history had arrow slits — small openings in the walls so archers could shoot through at intruders. These mostly lined the entranceways near gates, though dungeons might have them in other places. Of course there's gates that fall shut, barred doorways and a lot of options along those lines.
There might be areas with traps that can be activated by levers or pressure plates, and the bad guys will try to steer the characters into them, or at least, use the threat of these things to slow them down and keep them at bay.
Magic and unusual options
D&D being D&D, there's a lot more options beyond what you get in real life. There's obvious spells to create webs, walls, or lock doorways, but there's a lot of other ways magic can become very tricky.
- Summoning a swarm of bugs or rats to crawl (over, around) the party in the doorway, and attack or at least disrupt spellcasters.
- Using darkness, or an illusion to make it look like the enemy still threatens — while they've actually retreated from the doorway and are making their way to somewhere safer.
- Grease spells on stairs, or narrow walkways.
- Illusions of floor hiding pitfalls, making closed doors look like blank wall space, etc.
According to d20pfsrd.com, third party publisher Frog God Games' Megadungeon Rappan Athuk features one or more Zombie Hordes.
A horde is a pseudo-swarm consisting of medium-sized creatures, since regular swarms are limited to Tiny or smaller creatures. It is Colossal-sized and deals damage to everything sharing its space, just as a swarm does.
The rules for hordes are described in the Horde Traits in the creature description.
Horde Traits (Ex)
Hordes are not so called because of the size of the group but rather the size of the creatures that compose the horde. Unlike normal swarms, hordes are composed of Medium creatures which are usually a normal version of a creature but otherwise behave in a swarm-like manner. There are usually around 50 creatures in a horde. The net effect is that they take only half damage from piercing weapons but take normal damage from other weapons. In addition when the swarm is reduced to 0 hit points or lower and breaks up, unless the damage was dealt by area-affecting attacks, then 2d6 surviving members of the horde continue their attack, though now only as individual creatures. Otherwise, a horde conforms to all of the other swarm traits.
One particular point of interest is that a horde can split up into a number of individual creatures when defeated, unless it was nuked using area effects.
Another interesting feature is the modified Rend ability, that triggers when the horde deals 25 or more damage to a creature, which happens 20% of the time. AnyDice predicts an 22.52±7.24 points of damage on average.
At CR 14, it looks rather weak to me. The damage output is low, AC might as well be 0 at this level and a mere 110 hp. It's saves are low as well. The only high defense it has is HD, but that one isn't targeted very often.
A single fighter 8 with Str 22 and a +2 greatsword will deal 2*27 damage with power attack, potentially killing in two rounds what according to the d20 Encounter Calculator should be "Unbeatable".
For comparison, other CR 14 creatures are the Nalfeshnee Demon, or and Adult Red Dragon.
Best Answer
"Focused Fire" is a legitimate technique.
But there are many ways to deal with it.
If your Combats are small skirmishes, with all participants within reach of each other then the PCs all piling on to one foe at a time will work. And this sounds like the "less fun" problem you are having
Some of the techniques I have used are: