Out of universe it's clearly for narrative purposes. In the Battle Of Winterfell it's clear the writers wanted to show a clear feeling of dread and show a completely unstoppable army. So they chose to show the continuous onslaught. But obviously, Cersei still needed to be challenged and she just got refreshed with an army of sellswords, they could hardly do that realistically with only a few thousand survivors. So I think they simply brushed over this and hoped nobody would care too much (suspension of disbelief).
In-Universe it can also be explained partially by the way the army of the death fights. It is made clear they behave as a wave that keeps going until they reached Bran. Certainly at the end of the episode you can see fighting goes on all over the place. Most significantly they do not take their time to first clear out an area before marching on to the next area.
Keeping that in mind, we saw at least a part of the Dothraki horde returning after their initial defeat. It's also possible there are scattered groups fighting smaller groups of dead on the plains while being ignored by the main force. Though honestly I think it's a stretch to say this adds up to half the force.
Similar for the standing armies inside the castle, the fighting was going on all around, meaning many people on the ramparts/grounds survived. Given the chaos and the size of the castle this may actually add up to half the force surviving.
What really can't be explained are the Unsullied. The main bulk of their force was on the wrong side of the trench, we saw Grey Worm collapse their retreat, and we saw the dead come to a halt when the trench was on fire, notably not fighting against any remaining force, so clearly everybody close to the trench was dead. We also barely saw any unsullied later. Though honestly, I wasn't under the impression the unsullied army in episode 4 was half of what we saw in season 7/ early season 8, so maybe the war room statement was just wrong on the unsullied.