car wont start PLEASE HELPHELP

I own a 2006 Nissan altima 2.5. One day it wouldn’t start and all power was off. There was a clicking noise coming from the drivers side dash. The tow company came and he connected a battery charger to the battery and it started right up. He said the alternator showed fine. I drove it to Autozone and they said the battery was good. The next day the same problem happened. Clicking noise and car wouldn’t start. I opened the hood, adjusted the battery connections and then the power came on( interior lights, open door beep etc..) then I immediately tried to start the car and again all the power went out. When I turned the key to start it just made a short popping noise that kinda sounded like a spark and everything just completely died. This is what happened every time I attempted to start it when I regained power to the car. I put in a new battery and the power came on but again when I attempted to start it everything completely died.