.
I've been searching the net for a perfect answer for you but I'm unable to find one I'm satisfied with. Here's an explanation that I found helped.
.
"Oxygen is feeding the microbes that live in the air naturally. They go to work on the chlorophyll, sugars, starches and whatever else they find to eat. The issue is they seem to be facultative microbes which means they prefer oxygen but can start to process food anaerobically fermenting the cannabis in the process giving you that funky ammonia smell. Once the jars stabilize at a low enough humidity there is not enough moisture for the microbes to persist or once the food supply is used up cure complete."