As far as I know, Mega Stones were only said to have been created when the ultimate weapon irradiated various stones throughout the Kalos region. At least as far as the games are concerned, they have nothing to do with Diancie or the some energy expulsion from the Cave of Origin (I don't remember seeing anything about that... there was a big blast of energy that came from there after you defeated or captured Groudon/Kyogre, but that only destroyed the artificial weather that they had created, and had nothing to do with any meteorites or Mega Stones at least as far as I recall).
Rayquaza is an exception because it has a special organ in its body that, when combined with the energy in certain meteorites (which Rayquaza eats), creates a surge of power that allows it to Mega Evolve.
However, they have not really elaborated on where Key Stones came from, but if I had to guess, then I would say that they probably come from those rainbow meteorites that were said to have been slamming into the planet during one of Kyogre/Groudon's conficts, since the leader of the Draconids was able to trigger Rayquaza's Mega Evolution by praying to it.
If the meteorites that Rayquaza eats are of the same composition as the ones that I'm assuming shattered and became Key Stones, then that could be the tie between Rayquaza's ability to Mega Evolve, and the more common method of Mega Evolution that we see with all other Pokémon.