Too many heroic deaths for my taste.
This is a fantasy TV series. The genre is built upon bigger-than-life heroes (and their bigger-than-life deaths).
And if you're the Night King and the button of doom for the entire white walker army (i.e. you perish they all perish) then why bother being involved in the conflict at all? You have superior numbers and can just overwhelm the living without need for being on the forefront of the battle.
Remember that NK was originally human. My take is that he had an axe to grind and believed himself to be unstoppable, and part of his plan was to take out the Three-Eyed Raven, which I'm assuming only he could do.
Likewise for the human defenders, let's charge our cavalry into the darkness headlong into a superiorly numbered force and throw them away. Then let's keep the bulk of our forces outside the walls and allow the enemy or overwhelm and surround us with their superior numbers.
That's what cavalry would do against a large infantry force with limited missile weapons - they charge through, tear up the infantry, and do it again on the way back. And don't forget that the Dothraki were by far the most fearsome and deadly cavalry known in this world.
Defend from within the castle and atop the castle, setup hinderances outside the walls to slow the enemies advance and make them vulnerable to arrows, rocks, etc. and utilize chokepoints within the castle so that the enemy cannot use their numerical advantage against your forces (i.e. doorways, etc) allowing you to hold them at bay and rotate fresh troops in and exhausted ones out.
Did we watch the same show? They did exactly what you suggest here: defending from the walls after the retreat, placing hedgehogs and other obstacles all over Winterfell to slow the dead down once they got in, etc.
I got the impression that Jon and company had devised the best plan they could given their numbers, resources, and time. If anything about it is not so believable, it's that they had time to make the preparations they did (trenches, thousands of dragonglass weapons and arrows, etc.). I think they failed so badly simply because of the sheer numbers, and the problems of facing a mindless horde: sacrificing themselves to breach the burning trenches, piling up to make it easier to climb the walls a la World War Z, and NK being able to just lift his arms and create a whole new army from your dead comrades.
I'm not saying that the episode was perfect, but I loved it. I may have picked on Anthony's quotes in this post, but I think a lot of you are being overly critical and nitpicky about something that is ultimately a 90 minute distraction from the mundane but real world.