This might seem like a trivial question, but I am not very good at mathematics. If I am supposed to show that:
If $p$ is prime show that $p\mid a^2 \implies p\mid a$
I would do like this (I do not even know if it is a valid way to show the statement);
If $p$ is prime then $p\mid p$. So if $p\mid a^2$ it means that $a^2$ must have at least one factor $p$ such that $p\mid a^2$ and due to the fact that $a^2 = a \times a$, it follows that $p = a$. Thus $p\mid a$.
But that is not a formal proof, right? It is more like an informal proof. So my question is if there is a more formal approach to show that:
If $p$ is prime show that $p\mid a^2 \implies p\mid a$
I know that there exist different methods to show divisibility, but due to the obviousness of the statement I have a very hard time showing the statement without using a lot of words.
Suppose that $p\not\mid a$. Then $p$ is not in the factorization of $a$. Since $a^2$ has the same factors as $a$ with exponents doubled, $p$ is not in the factorization of $a^2$, so $p\not\mid a^2$. Contradiction.