Riker's actions on the Pegasus must figure in this somewhere. The implication was that his actions were so bad he could get court-martialed, so perhaps he figured keeping his head down as second in command was the best way of avoiding being compromised later.
No doubt. The incident with the Pegasus
came to light in 2370. Riker was awarded the Titan
in 2379. The intervening years saw conflicts with the Borg, the Dominion, and the Klingons. Riker almost certainly would not have been given a command so soon after Pegasus
. He had plenty of chances to distinguish himself following that, however, so it's not surprising that Starfleet would give him another chance after enough time had passed.