>>53121913Ultra Megapolis is, and never was, an "alien planet". It's the future of the main timeline, ala Future Trunks timeline. Only Ultra Space have properties to be called alien planets.
There's enough evidence to assume Necrozma created the UBs to rebel against Arceus, and the Tapus were specifically created to stop Necrozma.
Necrozma was created to be a being of emptiness and only be a way to refract and transfer light throughout the universe, until it rebelled. It brought the original Cosmog line to near extinction in the far past, eating enough to become Ultra Necrozma, with his powers becoming so strange from his universal feast on these species of Pokemon that it affected other inanimate/living things and turned them into UBs.
Kukui said in the beginning of USUM that "People and Pokemon united against darkness long ago", that darkness being Necrozma stealing light.
Necrozma was defeated by everyone in the past, and the UBs were locked away in either pocket dimensions or far away planets unreachable by man or Pokemon, unless it happened to be related to the Cosmog line, which Necrozma gained the powers of by eating so many.
Anyways, Lusamine in Sun and Moon opened Ultra Space up and the UBs escaped, but this woke Necrozma up as well in SM.
Canonically, the player did not catch Necrozma in SM, so Necrozma killed the player, fused with the respective version's legendary, and wiped out a good portion of humanity and Pokemon before they united again to seal Necrozma up in a tower they constructed to give light to the rest of the world and seperate the two legendaries.