During the time when the Enterprise-D (later E) was the flagship of the fleet, was Captain Picard necessarily the officer with the most seniority (of those officers that served regularly aboard ships)? Did Jim Kirk necessarily have the most seniority during his time, since his Enterprise was the flagship?
The way Starfleet uses the term 'flagship' has no bearing on the way it's used in any real navy. A flagship is the ship the admiral of a squadron or fleet rides on -- the ship carries the admiral's flag; and in the days when flags were used as signalling between ships, it was the admiral's ship from which such signals would issue! The admiral riding on that ship is in command of the fleet, while the captain of that ship remains in command of his ship.
Starfleet, however, tends not to gather together in squadrons except in extremis. Normal operation sees starships operating independently, and admirals mainly operating out of starbases, not riding ships at all. From this standpoint, in ordinary operation, Starfleet has no flagships.
Enterprise, however, dating back to NX-01, tends to a ship from whom people expect great things. Her CO is not necessarily senior -- even in the original continuity, James Kirk was one of the youngest captains in history at 30.
Interestingly, the CO of Enterprise isn't even necessarily someone Starfleet really trusts! Kirk is viewed as a maverick continually at odds with leadership; Picard, post-Borg, is viewed with suspicion.
Rather, the CO of Enterprise seems to be chosen for their ability to
- Pull a strong team together
- Make the most of that team
- Get things done, consistently, in a way that ultimately advances Starfleet and the Federation's interests.