I never fully understood why he's officially back at the helm in TFF though. Maybe Excelsior was still undergoing tests after the transwarp fiasco, and Kirk simply offered him another short term tour-of-duty until his own command was available again?
There's no cannon explanation for this, but the Crucible
books touch on it some. After the trial in which Kirk was demoted, he had a meeting with Admiral Cartwright to talk about what his next assignment would be. Cartwright told him that he was being offered command of a vessel with no senior staff, but didn't tell him the name (Enterprise-A
was a surprise). He also said that the other officers involved in the theft of Enterprise
would be unable to return to their old positions because of the drama surrounding the Genesis planet and the incident with the Klingon BOP.
Kirk asked if he could name any of the officers to his senior staff so that they would have jobs, and Cartwright was okay with it, adding that if the officers performed well under Kirk that they would have a chance to resume whatever tracks they'd been on prior to TWOK and TSFS.