All perfect praise be to Allah, the Lord of the worlds. I testify that there is none worthy of worship except Allah and that Muhammad is His slave and Messenger.
The money which you had paid to the agency in return for Hajj services left your possession and was transferred to the possession of the agency. When something is no longer in one’s possession, he is not obliged to pay zakaah on it. When the agency returned the money to you, your possession of it started anew, so you are not obliged to pay zakaah on it; rather, you start counting a new lunar year from the time it was returned to you. Since a whole lunar year did not elapse while it was with you, as you gave it to the second agency and so it left your possession again, you are not obliged to pay zakaah on it.
Allah knows best.