Though you have read the situation quite well, Commander is not- a synonym for First Officer. More and more, the term 'Commander' indicates top-honcho.
Very loosely - In the USA, 'Captain' seems to irrefutably be the guy in-charge, whereas in many other parts of the world the 'Commander' answers to that description and the overall trend seems to be in that direction.
So, in today's world,'Commander' indicates the person in-charge of a particular flight, legally, the PIC, Pilot In Command. Definitions may vary, but the FAA definition is quite representative:
Pilot in command means the person who:
(1) Has final authority and responsibility for the operation and safety of the flight;
(2) Has been designated as pilot in command before or during the flight; and
(3) Holds the appropriate category, class, and type rating, if appropriate, for the conduct of the flight.
On flights with augmented or multiple crew sets for longhaul and ultra-longhaul flights it becomes necessary to formally designate who is in-charge in the cockpit when the PIC of the flight is resting.
The following assumes a 2 pilot cockpit requirement and there are 2 ways this could be achieved:
Some operators/regulators require a qualified PIC in a cockpit position at all times, and such person is typically trained to sit on either seat (LH or RH) and call the shots when the PIC is resting. They would also typically alternate as PIC on legs they fly. A 3 person crew in such a setup would require 2 PIC qualified pilots and 1 FO so that whatever the combination, there's always a PIC qualified pilot in the cockpit.
On the other hand, Regulations typically permit P2's ie copilots/FO's to occupy the Commander's position in the cockpit as 'relief' or 'cruise' pilot, provided they meet experience requirements and provided they undergo a specified training syllabus including 'seat specific training'. In case of a 3 person crew, rostering could be as in case 1, and a further option of 1 PIC and 2 FO's of which atleast 1 would be qualified as 'relief' or 'cruise' Captain/Commander.
On multiple crew flights, eg a 4 person crew, it is typical to have 2 complete sets - 2 PIC + 2 FO, though there could be variations on this depending on regulations.
Nomenclature varies, Cruise/Relief/Second/Captain/Commander/Pilot and in many large, typically 'legacy' carriers this can serve as a sop for high-time FO's, recognizing their experience and competence, while they wait their turn for a decade or more in the Command seniority list. Qualifying could also have financial benefits. I've been there, just under 10 years to commence PIC training, after flying 2500 hours as a PIC with another airline operator on a turbo-prop.
For more regulatory info: § 121.543 Flight crewmembers at controls.