A Z-PAK contains a macrolide antibotic called azithromycin. After the last dose, the medication will remain in your system for about 360 hours (15 days). That doesn't mean it is at full strength during this period. 72 hours (3 days) after the last doses, half of the medication is out of your system; 3 days after that half of the half is out and so on.
I am not sure about what you are asking in the second part of your question. If your asking whether azithromycin can be taken for more than 5 days, the answer is yes depending on the indication for which your doctor presribed it. That being said, unless advised otherwise by your doctor, you probably wouldn't take two pills of the second Z-PAK on the first day like you did for the first.