It’s a classic, if somewhat exaggerated trope in Star Trek: The ships first officer, second officer, tactical officer, chief engineer, chief medical officer, and a random ensign beam down to an unsecured planet while some dangerous problem is either ongoing or likely to occur. The Doylist reasons for this are as obvious as the Watsonian reasons it seems so silly: these are the main characters who are supposed to get the bulk of the screen time, so they are constantly thrown into situations which real world commanding officers and department heads are generally kept well clear of.
But what if this wasn’t the precedent established in TOS and continued in every subsequent series (including, to a slightly lesser but very real extent, Lower Decks)? What would a Star Trek show look like which still had senior officers who we are meant to care about and who still get significant development and screen time, but who aren’t thrown into unrealistically dangerous situations on a regular basis? Could such a show survive telling stories without visibly putting those regulars lives on the line so frequently? Would it be viable to keep the focus on things that happen either aboard ship or in nominally safe situations? Alternately, could a show successfully develop a cast of lower ranking “away team” characters who get the “dangerous” screen time while keeping significant focus on the major decision makers on the bridge? And how could the shows manage such a visible separation between “expendable” and “not expendable” crew while maintaining that humanist, optimistic, everybody-has-an-equal-right-to-life ethos?
It wouldn’t be an easy thing to pull off, certainly. But how could it have been done?
I think the MACO example is a really great starting point though: have a few “away teams” that can beam down or beam over and take care of things. The exception being when circumstance requires a specific officer. In Enterprise during the Xindi conflict, MACOs handled certain off-ship actions. I think a similar situation in another franchise is Stargate SG-1/Atlantis, where the bridge crews never leave the ship and instead utilize teams (such as SG-1 or AR-1).
Starfleet claims they are not a military organization, but beams down with phasers (or phase rifles). Why not get a special team who is experienced militarily and instill first-contact procedures, diplomacy, and, if the need requires it, a science personnel who is trained to defend themselves.
With as many red/yellow shirts who have died, it makes sense to not endanger your senior officers who would have died without plot armor. For their credit, the MACOs were a step up from their plain security personnel.