There are silenced genes in certain pokemons' DNA that are generally kept off due to overexertion, but can activate during crucial times in the wild.
However, ever since the age of humans, Pokemon have never needed to activate these genes due to their more comfortable lives, so they haven't needed to activate these genes.
Due to a recent explosion in molecular genetics, Kalos scientists were able to sequence all known Pokemon's DNA and found a common thread among a good handful of them: these megas powers.
Archeologists then discovered that certain radioactive rocks are connected to these genes, as the enzyme that demethylates the DNA around those genes is trigger by very specific wavelengths. High energy as a specific wavelength simuatles the fatigue felt that activated the enzyme in the olden times, so it activates their megaevolution, completely changing their morphology and physiology until a silencer methylates those genes once again.
It's a bit too sci-fi for my tastes, but I thought of it in like 15 minutes