Brigade and Battalion level you have the Commander and XO Executive Officer who is the 2nd in command. Then it passes on down through the staff following a pre determined and usually practiced succession plan.
Company level you have your Commander then XO and down to the platoon leaders which are typically Lieutenants and those move up by date of rank. But I have seen Commanders designate succession in order based on real world experience as well.
At the Platoon level you usually have an experienced NCO Platoon SGT that is watching out for his Lieutenant and his troops. Below him there is always that one guy that everyone seems to gravitate too that has loads of real world experience and and everyone would follow should the Platoon lose its leadership.
This is just my on the job experience. I am sure given the vast amount and type of military units in today's Army there are many other methods at play. Not claiming to know it all.
I have been rereading an account of the Peninsular War, 1808-14. In the Duke of Wellington’s British Army, there were no XOs, one staff officer at Brigade HQ, maybe, but none below that, less than a handful at Division HQs, and a couple of handfuls at Army HQ. If a Division Commander was killed, seriously wounded, or home on leave, there was typically no replacement available, and for the months it took the Commander to recover, or for a replacement to sail from England, the senior Brigade Commander, Battalion Commander in that Brigade, Company Commander in that Battalion, Platoon Commander in that Company, and Sub-Lieutenant without a Platoon, temporarily moved up a step in command.