I mean my immediate team manager aka Mr. Manager and his manager, the engineering manager, both resigned
Most companies are organized enough that they have succession planning and contingency plans for managing work if key members resign (We kind of knew this was already an issue based on your other question about the lack of knowledge sharing). It should not be a matter of a vacuum getting filled by random happenstance. This would seem to be an indication of an organization with problems, from the top down.
The chaos and bedlam and the general Lord of the Flies environment that the resignations caused, and the fact that no one seems aware of it and no one has been assigned to take control of it is an indication of an organization with problems.
The fact that your senior developer has sole control and knowledge of the codebase you were supposed to be working on, and was able to deflect sharing that knowledge with you, successfully, to avoid others finding out what an undocumented, disorganized mess he had (aka, failure to properly do his job), is an indication of an organization with problems.
Generally, people higher up the ladder have more of a feel for the pulse of the company, beyond your own day to day perspective. If you trust your boss, and his boss, as competent professionals, their jumping ship should set off huge alarm bells for you, and serve as a sort of "canary in a coal mine."
If your relationship was good with your ex-boss, and you know of a way to contact him, ask about his departure, with assurances that it will be confidential (and keep that promise!). Say that you are a bit unnerved by what followed the resignation, and are evaluating your long-term future with the company. It may be something as simple as his boss getting an awesome offer, and getting to take your boss along with him, which means you shouldn't necessarily be concerned about the long-term viability of your employer. Or it may be that both of them see the company going down in flames, and are jumping ship while the going is good. Other indications you have shared would have me worried that the reason is "option B" in this scenario.
In a scenario like this, how does one ensure that one is able to pursue one's career trajectory successfully? What I mean is, I would love to be able to separate my career's advancement from this chaos.
Do you mean your career, period, or your career within this company? The two might not be entirely compatible with one another, if the company is coming apart at the seams. If you are able to manage the chaos and come out smelling like a rose, it might be the equivalent of getting a promotion to Senior Deck Chair Arranger on the Titanic, after it hit an iceberg. Protecting your career advancement might mean doing so with another organization.
Maybe, if you are able to talk to your boss, ask if he will keep an eye for opportunities in his new organization, if there is one. If he resigned, and was not let go, and didn't have any job offer in hand, then that would be an indication that things are bad where you are, as well.
I realize that this answer is probably useless in terms of addressing how you make the best of the situation within your current company. Other than recommending you go nowhere without a shiv in your pocket (just kidding, folks), I'm afraid I'd be out of my depth trying to advise you how to do battle in an unsupervised cage match setting.