So I was watching Volcanion and the Mechanical Marvel yesterday and I realized that it was still in Kalos. Then in the storyline they mentioned that magearna was actually made in Kalos from a city there. So why wasn't it in the Kalos dex, and in the Alola dex instead?
My answer is that I'm betting they just wanted to introduce in the next region, and simply thought there wasn't going to be an event for this Pokemon game, actually the next one. Or they didn't think about it, and then decided to bring Magearna into Pokemon games. After all, Magearna did also debut in Pokemon Sun & Moon: Ultra Legends.
Because Magearna was introduced in Gen 7 (Alola). X/Y were released in 2013, and Magearna was revealed officially on February 14th, 2016. Source: Magearna's Bulbapedia page