The imperium struggles each and every day from infighting, intergalactic and extragalactic threats, not to mention it is still recovering from the Horus Heresy. Despite the odds, the imperium still maintains a million worlds and has survived for over 10,000 years. How does the ruling body of the Imperium of man manage to do this?
It's mostly self governed with an overruling force on Terra
In 40K the imperium consists of over a million worlds as you said these worlds are hard to keep track off.
The IOM (Imperium of Man) is governed by the Adeptus Terra which is the central organisation body of the imperium. within the Adeptus terra are most of the official departments and organisations within the imperium. these fall under a general command structure as seen here.
The organizations that aren't within this command structure are the Ecclesiarchy, Adeptus Mechanicus, and the Inquisition. this command structure is headed by the High Lords of Terra the council consists of 12 Leaders of the most powerful organizations within the imperium, namely:
These following 9 are always on the council
The Master of the Administratum
The Inquisitorial Representative
The Ecclesiarch of the Adeptus Ministorum
The Fabricator-General of the Adeptus Mechanicus
The Grand Provost Marshal of the Adeptus Arbites
The Paternoval Envoy of the Navigators
The Master of the Astronomican
The Grand Master of the Officio Assassinorum
The Master of the Adeptus Astra Telepathica
whilst the remaining 3 positions are most likely to be filled by these
- Lord Commander of Segmentum Solar
- Lord Commander Militant of the Imperial Guard
- Cardinal(s) of the Holy Synod of Terra
- The Abbess of the Adepta Sororitas
- Captain-General of the Adeptus Custodes
- The Chancellor of the Estate Imperium
- The Speaker for the Chartist Captains
- Lord High Admiral of the Imperial Navy
You also have the Senatorum itself, and it is composed of tens of thousands of Imperial dignitaries, nobleman, lords, and other officials, but these rarely meet and instead the "High Twelve" conduct the vast majority of affairs.
Though after Roboute Guilliman was revived during the events of the Gathering Storm he took charge of the whole imperium as the Lord Commander of the Imperium and Imperial Regent. though he later reinstated the council of the High lords with Guilliman serving as their head.
The task of the High Lords is to interpret and enact the will of the Emperor. Accordingly, the position of High Lord was the most powerful in the Imperium until the reemergence of Roboute Guilliman, who declared himself Imperial Regent, or the Emperor's Living Voice
Because of how many worlds there are within the imperium and how vast it is, it's pretty much impossible to have a single central goverment. therefor each planet is governed by a Planetary Governor whom is to rule a imperial planet and is free to run set planet as he/she chooses. as long as he/she keeps control over the planet's Tithes (resources given to the imperium) and the numbers of mutants and psykers on the planet. each planet has their own planetary defense force and orbital defenses.
You also have some planets and systems that follow their own command. most notably the realm of Ultramar, which is lead by the lord of Macragge which is the current chaptermaster of the Ultramarines space marine chapter. and 4 Tetrarch's which are the leaders of the 4 sub sectors. whom are the leaders of the Planetary Governors of the planets.
TL;DR The imperium is largely ruled by hundreds of thousands of Planetary Governors each ruling a planet or planet's with exceptions there, but they are all bound to the larger imperium which is ruled by the adeptus terra, which itself is headed by Roboute Guilliman and the 12 High lord's of terra.