In the film continuity the Stones were created at the beginning of the universe by the Cosmic Entities (Death, Entropy, Infinity and Eternity, according to background visuals in Guardians of the Galaxy), who used pre-Big-Bang "singularities" to craft them.