>>40893269In a nutshell: Lysandre goes after one of two Zygarde cores in an effort to have snake Zygarde wreak havoc on Lumiose City using strange roots. When this fails, he conveniently pulls out a giant Zygarde rock (originating from Hoenn), which could collide with the Anistar City Sundial and release enough energy to wipe out all life on the planet. Ash and co., Alain, Diantha, Steven, Malva and the Kalos gym leaders delay Lysandre, but it's Complete Zygarde (comprised of two cores) that destroys the giant rock. The end.
Even more concisely: Zygarde destroys threats to the planet. That's its all whole shtick and you might as well just pretend that it destroyed the Ultimate Weapon in XY, even though the protagonist intervened first. These scenarios are so reductive, anyway.