First of all, if one assumes ring-theoretic definition of prime, this whole exercise is trivial. So, we obviously won't, we will assume that "prime" means positive integer with exactly two divisors in $\Bbb N$.
One needs to be careful not to fall into circularity here, so let me introduce terminology.
We will call positive integer $p$ $\Bbb N$-prime if $p$ has
exactly two divisors in $\Bbb N$.
We will call (integer) $x$ prime if $x\mid ab\implies x\mid a$
or $x\mid b$.
We will call $x\in \Bbb Z\setminus\{0,\pm 1\}$ irreducible if
$x = ab\implies a =\pm 1$ or $b = \pm 1$.
Thus, we can reformulate your exercise as
Every $\Bbb N$-prime $p$ is prime in $\Bbb Z$.
because we would then have $p|a^2 \implies p\mid a$ or $p\mid a$.
Lemma. $x$ is irreducible in $\Bbb Z$ if and only if $|x|$ is $\Bbb N$-prime.
Proof. Assume that $x$ is irreducible and that $d\mid |x|$ in $\Bbb N$. Then $x = \pm nd$ for some $n\in\Bbb N$, but since $x$ is irreducible, $d = 1$ or $n= 1$, i.e. $d = 1$ or $d = |x|$.
Conversely, if $|x|$ has exactly two divisors in $\Bbb N$, and $x = ab$, then $|a|,|b|\in\{ 1,|x|\}$, but that means that either $a = \pm 1$ or $b=\pm 1$.
In general, we know that every Euclidean domain is unique factorization domain, and also, we know that in UFD $x$ is prime if and only if $x$ is irreducible.
Thus, if we can prove that $\Bbb Z$ is Euclidean domain, then it is UFD, and thus if $p$ is $\Bbb N$-prime, it is irreducible in $\Bbb Z$ by our Lemma, and hence prime, which would finish the proof by the above remark.
Theorem. $\Bbb Z$ is Euclidean domain with Euclidean function $f\colon\Bbb Z\setminus\{0\}\to \Bbb N$, $f(x) = |x|$.
Sketch of proof. Let $a,b\in\Bbb Z$ with $b\neq 0$. For simplicity let us assume that $a,b>0$.
We want to show that there exists $q,r\in \Bbb N$ such that $a = bq + r$ and $0\leq r < b$. Let us define $q = \min\{n\in\Bbb N\,|\, nb > a\} - 1$ (existence of $q$ is guaranteed by well-ordering of $\Bbb N$) and define $r = a - bq$. Then we have $$bq \leq a < b(q+1)\implies 0\leq a - bq < b \implies 0\leq r < b.$$
General case where $a,b$ are not necessarily positive can be deduced from this by playing with absolute value.
Of course, for $a,b\neq 0$, $f(a)\leq f(ab) \iff |a| \leq |ab| \iff 1\leq |b|$ and we are done.