According to
https://ufopaedia.org promotions are given according to a "promotion score". The formula for that score has a great deal to do with a soldiers basic stats, seemingly as much or more than their combat performance or participation. That's why soldiers
sitting in your base are being promoted even when they aren't on missions - their stats have given them a "promotion score" that exceeds the troops you just took on a mission even above someone who just single-handedly took out 6 aliens and kept his cool when others panicked. Even the most heavily-used trooper you have with gobs of kills and a dozen missions under his belt can be overlooked for promotion because some rookie schmuck you just hired to replace losses has better stats.
The advantage of officers is actually only the morale effects. Having officers on missions provides a morale bonus when aliens are killed - as well as a morale penalty when an officer is killed. Officers don't shoot better. They don't resist psi attacks better.
They only adjust morale. Because of that, the higher the rank of the officer the less you actually want to expose them to danger on a mission because it can cause a cascade in panic. A colonel gets killed and the sergeant panics - which gets the sergeant killed and drops morale again to the point where the captain panics, and then gets killed... and then it's a massacre. And that's just with being shot - it doesn't include being panicked or taken over by psi attacks.
Now, out here in the real world we tend to think of these promotions in terms of it being a
field promotion - which should be based on your display of competence on an actual mission. But in the game that's only part of it. Mostly it's better that you think of it in terms of all your troops repeatedly undergoing tests and running obstacle courses back at base and the one with the best overall score in those competitions gets promoted first - with a bonus for doing well on missions. Then every time you complete a mission those competitive test scores are checked again back at base and if there's room for promotions they get handed out again. But you don't have to be doing missions and killing aliens to do really well on those promotion tests.
Really, that's kinda bass-ackwards from how we seem to reflexively think it should work. It FEELS like the troops with the best in-mission performance should be the ones getting all the promotions - and then if there's a TIE the trooper with the highest stats gets the promotion. The reality is that the trooper who just came off a really great mission will be ignored if he doesn't have good stats. Actual combat performance is HIGHLY undervalued for promotions.