$\ce{Al2(HPO4)3}$ is a compound made of $2$ ions $\ce{Al^{3+}}$ and $3$ ions $\ce{HPO4^{2-}}$. In total, this produces $6$ positive charges, and $6$ negative charges. Both number of charges are equal in the formula. Total zero. This is needed to get a neutral substance. Now, in the formula, the positive ions is at left, and the negative charges are at right. So the formula is all right. It is not absolutely forbidden, but usually it is not necessary to include the charges in the formula.
Same thing happens in the substance $\ce{CuH2PO4}$, which is made of $2$ ions, one $\ce{Cu+}$ and one $\ce{H2PO4-}$. In total, this substance contains $1$ positive ion, and $1$ negative ion. The total is zero. This is needed to get a neutral substance. Now in the formula the positive ion is written first, then the negative ion. The final formula may contain the individual charges, but usually, these charges are not necessary. So they are not part of the formula.
For the last question, you should not compare $\ce{HClO}$ and $\ce{HClO2}$ which are different substances, without any connection between them. They cannot be exchanged or compared.