>>37560164The anime is largely canon only to itself, but as the anime also runs on a multiverse that was confirmed with M20, some of those anime based universes collude with the game universes, leading to things like Ash-Greninja, Alain and a few other things being canon to the games, but the exact events of the anime aren't necessarily canon themselves.
ORAS shows the Mega Evolution Specials did happen before the player's journey, the Alola Games show that the events of Kalos played out differently enough that Ash didn't release Greninja and instead gives it to (You) for the Special Demo, and Ash himself is evidently well-known enough to be featured on a poster as seen in Totem Mimikyu's Room.