Star Trek
In Star Trek, a flag officer has never been shown on screen as a regular part of a vessel's crew. When an admiral is aboard a Starfleet vessel (as seen in Too Short A Season and The Pegasus, among others), he is there for a specific mission. He commands the mission, but he does not command the vessel. However, when the mission is over, the admiral leaves.
Star Trek doesn't use the modern definition of "flag ship". Real navies operate together, rather than the widely scattered formations you see in Star Trek. A Federation fleet is an administrative unit, rather than a functional unit. In fact, in Redemption and Redemption, Part II one of the few places you see a functional fleet is lead by a non-flag officer, Picard himself.
Real World
In a real navy, the presence of an admiral aboard1 is what makes a vessel a flag ship - the admiral is said to be "flying the flag" from the vessel. The admiral aboard is responsible for the fleet's overall mission parameters and decides where to go and what to do for the fleet at large (based on orders from higher up). The individual vessel commanding officers determine how to do what's been asked of them.
While the admiral aboard may have done the captain's job in the past, there is a hard break in responsibilities. The admiral and staff manage the mission, the captain manages the vessel. An admiral interfering in the vessel commander's designated role can lead to problems that trickle down the entire chain of command - it isn't done to avoid such problems.
Flagships by Construction
Commonly, the vessel used as a "flagship" is selected because of the available facilities onboard. Modern US Navy aircraft carriers have large numbers of cabins dedicated to the admiral, admiral's staff, and their information and communications needs. The French even have a replenishment ship with flag capabilities.
Generally speaking, this means a "flagship" is the biggest, most modern vessel, and frequently well-known vessel. This is the context that Star Trek implies when they call the Enterprise a "flagship". It (theoretically) has flag capabilities, even when there is no flag officer aboard.
Line Officers
Real militaries have the concept of line officers, officers who are trained to take general command of a situation. In Star Trek, most of the bridge officers are line officers, while most other officers are not2. Completing the Bridge Officer's Test is what makes somebody Star Trek's equivalent of a "line officer".
In many cases, officers such as medical officers, counselors, and engineers, don't take the Bridge Officer's Test because it doesn't help them with their job responsibilities. Crusher and eventually Troi take it because they want something more, they want to expand their skillset. There are many officers who have no such interest.
When the commanding officer and executive officer are off the bridge, one of the available line officers takes over. That's how somebody like Geordi can end up in command in early episodes, despite not having a high rank - he's taken the Bridge Officer Test as part of his training, others haven't.
Hollywood Conceits
In the real world, what we saw in Redemption would almost never happen. A lowly captain would not be in command of that many vessels and would not be managing a mission of that nature. That's the kind of thing an admiral would be onboard for. None of the interaction between Data and Picard would have happened, because Data would be dealing with the flag admiral aboard the Enterprise. It's more interesting for the audience to see interactions between established characters.
The same applies to Crusher and Troi. While there's no really good reason for health services officers to be trained for command, it's good character development. In the real world, you're not likely3 to find two MDs or PhDs serving on the same vessel as line officers.
TLDR
Your older-and-higher-ranked concept is unrealistic. It is in conflict with basic organizational protocols. Such characters would not be part of the ship's normal complement or chain of command - in the long term, it would only create confusion and dissension. They could be onboard for a special mission, but they would leave when it's over.
1Assuming the admiral is aboard as active part of his duties, not as an observer or inspector (like McCoy in Encounter at Farpoint). Sometimes an admiral is along just because the ship is going the right direction, or to interact with some civilian dignitary onboard.
2Star Trek tends to be very officer-heavy, while real-world militaries are not. Chock it up to Hollywood.
3Anything's possible, though.