That was mainly due to https://tvtropes.org/pmwiki/pmwiki.php/Main/ViewersAreMorons combined with Riker being relatively young for the substantive rank of Captain. He would certainly have been confirmed as a Captain if he'd remained as CO of the Enterprise.
We certainly see Riker continue as captain in Picard's absence in "Parallels"; and of course there's that fan theory that Riker was deliberately left on the Enterprise as a "backup captain" in case Picard wasn't entirely reliable after he was de-assimilated, instead of being spirited away to be given his pick of the rebuilt fleet.
Riker was 31 at the time of "The Best of Both Worlds", but young captains are hardly unprecedented in Star Trek. Kirk was 32 when he became captain; Picard was 28. Janeway was (probably) 35 when she took command of Voyager, and there's some evidence that she captained another ship beforehand though it's never made clear in the show itself.
Rice, Janeway, Ransom and maybe even Sisko prior to the Dominion War should all have been "Junior Captains" wearing a lower rank (either the existing LCDR and CMDR ranks or the intermediary rank that has mostly been unseen on screen.
Sisko did have a lower rank to begin with; he was commander at the beginning of DS9 only became captain at the end of the third season to reflect the station's increasing importance and the diplomatic role he'd played with Bajor. But yes, I wondered for a long time if this is where commodores and fleet captains might come into play.