Statement to be proved:
Prove that if $n > 1$ is not divisible by any prime number $p$ where $p \le \sqrt{n}$ then $n$ is a prime number.
Suppose we assume that $n$ is composite. We then prove that $n$ is divisible by a prime number $\le \sqrt{n}$.
We proved that a composite number is divisible by a prime number $\le \sqrt{n}$. Can we fairly deduce from this that a prime number is not divisible by a number $\le \sqrt{n}$? I doubt this. As far as this proof is concerned, for all we know, both composite and prime numbers could be divisible by a prime number $\le \sqrt{n}$. Where is the contradiction?
Your question really concerns the logic of contrapositives. You are proving that a sufficient condition for $n$ to be prime is that no prime number less than or equal to $\sqrt n$ divides $n$. One way of doing that is to show that a necessary condition for $n$ to be composite (negation of $n>1$ being prime) is the negation of the condition given above.
So, the logic works as follows. You want to show $P$ implies $Q$ (so $P$ is the sufficient condition). The method is to prove the contrapositive of the implication, that $\neg Q$ implies $\neg P$ (i.e. proving $\neg P$ is a necessary condition for $\neg Q$). Given that the contrapositive has been proven, one can be certain of $P$ implies $Q$ as well. One way to see that is to compare truth tables. But, one may be convinced the following argument: $P\implies Q$ follows from $\neg Q\implies \neg P$ since $P$ and $\neg Q$ would entail $\neg P$ a contradiction.