I know that $$\phi(m)=m\prod_{i=1}^{n}\left(1-\frac{1}{p_i}\right)\text{ Where }m=\prod_{i=1}^n p_i^{a_i}$$
But when i tried to find a formula of $\phi(n)$ i got this: $$\phi(m)=\phi \left(\prod_{i=1}^n p_i^{a_i}\right) = \prod_{i=1}^n \phi(p_i^{a_i}) $$ Now since $\phi(p^m)=p^m -p^{m-1}$, Thus: $$\phi(m)=\prod_{i=1}^n \left(p_i^{a_i}-p_i^{a_i-1}\right )$$
Is this’s a valid proof? and if it is why most people are using this formula: $$\phi(m)=m\prod_{i=1}^{n}\left(1-\frac{1}{p_i}\right) $$ Side note:
I’ve used the same method to find the formula of $\sigma(n)$ and $\sigma_m(n)$
Your proof is valid (assuming you already proved the facts you used about $\phi$). Both formulas are practically equivalent
$$\prod_{i=1}^n (p_i^{a_i}-p_i^{a_i-1} ) =\prod_{i=1}^n p_i^{a_i}\left(1-\frac{1}{p_i}\right) = m \prod_{i=1}^n \left(1-\frac{1}{p_i}\right) $$
and both are widely used.