It can be confusing, especially when mixed in with real world descriptions.
In the U.S. Navy, commodore used to be the lowest flag rank, now referred to as 'rear admiral, lower half.'
The term 'commodore' is still used, however, as a form of address to the commander of a destroyer or submarine squadron, or a land-based air wing. (Carrier based wing commanders are referred to as 'CAG' for reasons I'll leave alone here). Such a squadron / wing commander is usually a captain, or O-6, but since ship's commanders (even at the O-4 or O-5 rank) are addressed as 'captain', the commodore title is used instead as a way of acknowledging the squadron commander's rank and authority.
In Trek, 'commodore' appears to have its older usage- that is, as the lowest flag rank. The fact that Commodore Decker commanded Constellation was a mere plot trick to make him senior in rank to Kirk, so that there could be that conflict when he tried to commandeer the center seat on Enterprise. It's the only time we've seen a flag rank officer commanding a starship (except for Kirk himself), and that's why.
I think the term 'Fleet Captain' in Trek should be considered the same form of address that 'commodore' fills in the modern navy- that of a squadron commander, or in particular, when there is a grouping of ships with no flag officer present to assume command of the entire force. In that case, an officer is designated 'fleet captain' and assumes overall command of the assembled ships. Like Pike in the Nebula when they were building the fueling station. I would imagine that being designated a 'Fleet Captain' in Starfleet is considered something of an honor, and someone with that designation automatically assumes that role in any situation where it is appropriate. If two Fleet Captains are present, then the senior one would naturally assume command, or command would be designated by Starfleet Command.
There is also a bit of precedent in the Royal Navy, I believe. The captain of the ship with a flag officer is (or used to be, in the age of sail) referred to as the 'Flag Captain.' However, I'm not sure what measure of extra authority, if any, that title carried.
The USN descriptions are factual, while the Trek ones are merely my opinion. Just so the two aren't confused.