Just thought I'd point out few things to help answer this question.
First off we 90% of the time see the same flag crew e.g. Janeway, Tuvok, Chakotay, Paris or Picard, Riker, Worf, Data, etc. However this is a ship that aside from refits is going to be operating 24/7 365 days a year. Now at a minimum you're probably going to be looking at 3 people per position day shift, night shift and relief for if someone's sick, on leave, on an away mission etc. You can probably have the relief cover a number of positions as they'd only be working when someone isn't able to fulfil their normal role for a reason.
It's quite probable that a ship operates on a 6 or 8 hour shift role rather than a 12 hour one e.g. 8 on shift, 8 off duty for personal interests and 8 hours for sleep. It may even as I said be 6 or some other futuristic value to reduce fatigue however that's another topic. So you need to take every single position we see and double/triple that for number of normal operational crew then assign a relief to ensure that those roles are covered at all times barring a massive incident that takes out multiple crew.
Now I think that starts to account for the number of red shirt (command) position staff we see wandering around they need those numbers because every single position on a fully staffed ship is going to have 3 people for that position (assuming an 8 hour shift) and a floating pool to draw on in case of one of those 3 being unavailable. Which brings us to point 2.
This is sort of a meta one in that this is a TV show so they want us to identify and care about their characters so they will have a core set of actors and extras for special situations (usually dying horribly in their red or gold shirt). The point here is a ship especially one of the size we see in Star Trek is going to have a lot of roles that need crew to man them for example shuttle pilots. You aren't going to take your Ace pilot qualified on a dozen ship classes and have him fly the shuttle down to the surface every single time. No he's going to be on the main ship to fly it unless this is his shore leave or its an extremely dangerous mission/shuttling an important figure. However in a show if we got a regular changing crew of pilots many dying when the shuttle blows up we aren't really going to care about them so instead we get the same actor flying the shuttle to make us identify with him unless they want the shuttle destroyed. So in a lot of these situations where we see the same character in real life that would be one of those background red/gold shirts.
Similarly we see emergency situations where they want their A crew on the bridge and we do on occasion see an extra being relieved of their spot in favour of a named actor. This is a Beta or Gamma shift red shirt taking the midnight to 8 am shift surrendering control of their station to the senior and more experienced crew member. We don't see the 8 hour "All ahead full Jackson, All Ahead full Jackson, All Ahead full Jackson." "I get it sir we're just flying ahead and doing nothing." "Look Jackson all I get to do is tell you to keep flying on the captains path and wake him if something interesting happens so excuse me if I take the chance to do the ONE JOB that . . . brilliant, insightful and dashing captain of ours lets me do." "He's not standing behind you sir." "Right, good, All Ahead full Jackson." because it wouldn't be interesting.
Then we get the one mentioned before that this people are on the ship for experience so they're shadowing and reporting on various departments in non-emergency situations to gain experience. However when the episode starts and things start going wrong they move away from these vital stations to escape pods, secured quarters and other areas as their emergency station. Because until they have moved from apprentice learning on the job about a working starship to qualified and merely improving their skills you don't want them bumping or trying to overrule a fully experienced and trained crew member because they're command and he's just an engineer ensign. They're their for normal on the job experience under direct supervision then as they move up the start doing indirect supervision and then actually taking command in junior positions where they are still learning but now they remain at that station in an emergency.
Finally there are a huge number of areas on the ship that we don't normally see. We see engineering at the warp core, the bridge, ten forward in TNG, transporters, sick bay and so on. However we also often hear these places referred to as Place X e.g. holodeck 2, transporter bay 3. So on these large ships there's probably a lot of duplicated places to allow for servicing the needs of hundreds of crew members. Kirk's Enterprise which was the smallest had 430 crew and 14 science labs. The Enterprise D could have up to 6 THOUSAND crew on board. That's going to need an awful lot of duplicated areas and thus a lot of command staff as well as engineering and science ones to cover those areas.
So we have multiple people for the same position, named actors we're meant to identify with being the same person each time on a job whereas on a ship you'd normally have different ones, people on the ship for training but who's emergency position is in a safe location and a large number of jobs/positions we simply never see because they aren't of interest for a show to television producers.
I hope these can help explain why we might see so many red shirts walking around in the background but not normally coming forward and taking command or doing things.