There are small and large leak codes for the evaporative emission system that can be triggered by a loose gas cap...as well as a number of other things. My guess is that you may have/had one of those codes stored? Did you confirm that the gas cap was actually loose or did Autozone tell you that the code was caused by a loose cap simply based on the code and not necessarily confirming that the gas cap was loose? The leak codes were once (and maybe still are) known as the "gas cap codes." Many gas caps that were perfectly fine have been replaced because parts stores told people that the code indicated a loose or faulty cap. Truth is that most of the time it's something else, like a stuck open evap vent control valve, or a split/disconnected hose in the evap system or even a leaking fuel pump module or fuel sender "O" ring.
If you problem was indeed a loose cap, it usually takes a good trip cycle to turn the light off and 50 trip cycles to clear the code from the ECM memory. Autozone should have cleared the code for you when they looked at it. If they did and the CEL came back on, then you likely have another problem and not a loose cap.