The wildfire was hidden there for many years. During his last moments, Mad King Aerys Targaryen II was planning to blow up King`s Landing with wildfire , which is the reason why Kingsguard Jaime Lannister killed him (S03E05- Kissed by Fire), and his last words were "Burn them all!"(S01E03, Lord Snow, S06E06, Blood of my Blood).
He secretly gathered thousands of jars of wildfire under the city, with most of them being placed under the Great Sept of Baelor, the Dragonpit and the Red Keep (A Storm of Swords- Jaime V) .
When Tyrion visits Hallyn the Pyromancer to get wildfire for the Battle of the Blackwater,Hallyn says that there are about 7.840 jars of wildfire with about 4.000 coming from the Mad King's failed plan, and that he is positive that he will make 10.000 before the Battle (ACOK, Tyrion V).
We don't know how many of the jars were used, but it is impossible that Tyrion used them all.Therefore there are still some jars under King's Landing.
Cersei must have known somehow about the wildfire. She was the queen, and in the show she was the first who thought wildfire could be used in the Battle of the Blackwater (S02E05 -The Ghost of Harrenhal).
In S06E08- No One Qyburn tells Cersei :“That old rumor you told me about — my little birds investigated” to which she replies :"Tell me, was it a rumor or something more?" and he tells her: "More, Your Grace. So much more."
It's obvious now that they were talking about the wilfire.
We don't know exactly how Cersei planned this to so much detail, so these are the only things I can tell for sure. The rest of this is shown in the episode itself (S06E10- The Winds of Winter.)