Here are some ideas, that the Aztecs needs to do for reforms.
1. Adopted European Weaponry- Kind of obvious, the Aztecs should adopted weaponry like musket and steel armor from European traders
2.Reform the Military ideology- Even if the Aztecs beat the Spanish, there's going to breakaway vassals, and ravaging states due to plague. They need to reshape their entire military identity, and focus on killing the enemy instead of capturing prisoners for sacrifice. This brings up to-
3. Reform the Religion- Human Sacrifice needs to go. End the powerful priesthood. Now with plague going around killing most of the population, every man counts. Plus, need to make yourself more appealing to Europeans who can trade with you. The other option is to convert to Christianity.
4. Centralize power to Tenochtitlan- The Huey Tlatoani needs to centralize power to himself, and make the Aztec Empire, instead of keeping the who vassalage system, make the empire at best federal like (future German Empire), and if they don't, or they'll end up like the HRE. Speaking of Huey Tlatoani-
5. Create a line of succession- There was a Imperial Family (Calling TTL the House of Tenochtitlan), but the position of Huey Tlatoani was elective.
Now, this isn't going to happen immediately after the Spanish failed invasion.
Cuitláhuac or
Cuauhtémoc could try to help, but they would be very limited, and not immediate. For these reforms, you need future Huey Tlatoani to be iconoclastic, not caring for the tradition, who has the foresight about the weaknesses, and create a new order in Mesoamerica, using the tools of European.
If the Aztecs successfully does these reforms, and somehow make it to the 17th Century - 19th Century, here are more reforms they need to do. (Reminder, this is highly theoretical)
1. Adopt certain aspects of European culture- Things like European clothing, European art, and European architecture. Best recommended is French, since they were very flamboyant in the 17th Century, with embroidered clothing, and large feathered hats, which sounds appropriate for the Aztecs
2. European style of military uniformity, and form a navy- Continue to advance through the ages, as tactics and navies improve, so does the Aztecs.
3. Industrialize- During the Industrial Revolution, the Aztecs would need to industrialize to keep up with the Europeans in the 19th Century.
4. Move the capital- As much as Tenochtitlan is a cultural marvel and aspect of the Aztecs, it may prove to limited to have a modern city in. They would need to create a new capital to have a new industry. Still, Tenochtitlan can remain a symbolic capital and cultural icon.
5. Expand- If Spain somehow colonizes some parts of Latin America, like Northern Mexico, California, Rio de la Plata and Panama, if they still get independence, and formed nations, they could be conquered, since if the USA still forms, the Monroe Doctrine wouldn't apply to the Aztecs.
Now this is merely hypothetical, but those are some of the things I think the Aztecs would need to do in the future