\(n_{Mg}=a\left(mol\right),n_{Al}=b\left(mol\right)\)
\(m_{hh}=24a+27b=7.5\left(g\right)\left(1\right)\)
\(n_{H_2}=\dfrac{7.84}{22.4}=0.35\left(mol\right)\)
\(Mg+2HCl\rightarrow MgCl_2+H_2\)
\(2Al+6HCl\rightarrow2AlCl_3+H_2\)
\(n_{H_2}=a+1.5b=0.35\left(mol\right)\left(2\right)\)
\(\left(1\right),\left(2\right):a=0.2,b=0.1\)
\(\%Mg=\dfrac{0.2\cdot24}{7.5}\cdot100\%=64\%\)
\(\%Al=100\%-64\%=36\%\)