To answer the more general question added in your edit: yes, one can apply a similar brute force case analysis to deduce that $\,5\mid n^2\Rightarrow 5\mid n.$ It suffices to check, mod $5,\,$ that none of $1^2,2^2,\ldots 4^2$ are $\equiv 0.\,$ Such a brute force case-analysis works for any fixed prime. But in order to prove this generally, i.e. that for all primes $\,p,\,$ it is true that $\,p\mid n^2\Rightarrow p\mid n,\,$ further properties are needed, namely the Euclidean (division) algorithm. Iterated, it yields the Bezout Identity for the gcd, which then yields Euclid's Lemma. This implies, as a special case, the Prime Divisor Property. This then easily implies the uniqueness of prime factorizations. Below is one simple way to proceed.
Euclid's Lemma $\,\ a\mid bc \,\Rightarrow\, a\mid (a,b)c,\ $ where $\ (a,b) := \gcd(a,b)$
Proof $\ $ By Bezout, we know $ \ ja\!+\!kb\, =\, (a,b)\,$ for some integers $\,j,k,\, $ so
$\quad \color{#c00}a\mid \color{#c00}{bc} \,\Rightarrow\, \color{#c00}a\mid j\color{#c00}ac+k\color{#c00}{bc} = (ja\!+\!kb)c = (a,b)c\quad $ QED
Now, considering Euclid's Lemma in the special case $\,a = p\,$ prime yields
$\,p\mid bc \,\Rightarrow\, p\mid \color{#0a0}{(p,b)}c,\ $ so $\ p\nmid b\,\Rightarrow\, p\mid c,\ $ by $\ \color{#0a0}{ (p,b)=1}\,$ if prime $\,p\nmid b$
Thus we have $\,\ p\mid bc \,\Rightarrow\, p\mid b\,\ \ {\rm or}\,\ \ p\mid c\ \ $ (Prime Divisor Property)
Thus we have $\,\ p\mid b^2 \,\Rightarrow\, p\mid b\ \ $ (special case $\, c = b\,$ of prior), $ $ as desired.
The Prime Divisor Property easily yields the uniqueness of prime factorizations, since it implies that we can match and cancel primes in any two factorizations. But once we have uniqueness available the irrationality of square roots of primes follows by a simple, beautiful parity argument:
$\sqrt{p} = a/b\, \Rightarrow\, p b^2\! = a^2.\, $ It follows from uniqueness that $\,pb^2$ has an odd number of factors of $\,p,\,$ but $\,a^2$ has an even number, contradicting the uniqueness of the prime factorization of $\,a^2$.