Number of matrices whose determinant is indivisible by a prime $p$ 
Let $p$ be an odd prime number and $T_p$ be the following set of $2 × 2$ matrices :
$$T_p=\left\{A=\begin{bmatrix}a&b\\c&a\end{bmatrix};a,b,c \in \{0,1,2\cdots\cdots p-1\}\right\}$$
Find $n(T_p)$ such that $p\nmid |A|$

The number of distinct elements in $T_p$ is $p^3$
Finding the number of matrices such that $p\mid |A|$:
Since $\Delta=a^2-bc$, let $kp=a^2-bc$
Case 1) $k=0 \implies a^2=bc$ leads to $p$ matrices($*$)
Case 2) $k>0$:
$$(a-\sqrt{bc})(a+\sqrt{bc})=kp$$
since $k<p$,
$$a-\sqrt{bc}=1,a+\sqrt{bc}=kp$$
or
$$a-\sqrt{bc}=k,a+\sqrt{bc}=p$$
Solving the two systems individually:
$$a=\frac{kp+1}{2},\sqrt{bc}=\frac{kp-1}{2}$$
$$a=\frac{p+k}{2},\sqrt{bc}=\frac{p-k}{2}$$
$k$ is strictly equal to $1$ for the first system and is odd for the second
$$a=\frac{p+1}{2},\sqrt{bc}=\frac{p-1}{2}$$
$$a=\frac{p+k}{2},\sqrt{bc}=\frac{p-k}{2}$$
I tried assuming $b=c$ to get rid of the square root, but couldn't justify it.
How do I proceed?
PS: Similar question has already been posted on MSE before, but I wish this to be answered separately.
($*$) There are more than $p$ cases, as pointed out in the comments
 A: If $a=0$ then $b$ must lie in $1,\cdots,p-1$ and $c$ must lie in $1,\cdots,p-1$, for $-bc=|A|$ to not be divisible by $p$.  Thus we have $(p-1)^2$ possibilities.
On the other hand, if $a\neq 0$ then we have $p-1$ possibilities for $a$.  For each of these we have $p^2$ possible choices of $b,c$ in total, but we must discard all those where $p|a^2-bc$.
Given some fixed value of $a\neq 0$, from the $p^2$ possibilities for $b,c$, we wish to discard those combinations of $b,c$ which result in $p|a^2-bc$.  As $p$ does not divide $a^2$, the cases we discount are restricted to ones where $b\neq 0$.  There are then $p-1$ possible values of $b$ which may give rise to a matrix we wish to discount.
We claim that for each value of $b$, there is precisely one value of $c$, such that $p|a^2-bc$.
If we accept this claim then for each value of $a$, there are $p-1$ cases that need to be discounted, leaving $p^2-(p-1)$ values for $b,c$.  As there are $p-1$ non-zero values for $a$, we have
$$(p-1)(p^2-(p-1))$$ matrices with $a\neq 0$.
Thus in total we have $$(p-1)^2+(p-1)(p^2-(p-1))=p^3-p^2$$ possibilities.

Proof that if $a,b$ lie in $1,\cdots,p−1$, then there is a unique value of $c$ in $0,1,\cdots,p−1$ for which $p|a^2−bc$.
Fix $a,b$ as above.
Consider the map $f$ from the set of numbers $S=\{0,1,\cdots,p−1\}$ to itself, given by multiplication by $b$, followed by taking the remainder after division by $p$.
If $f(x)=f(y)$, then $bx$ and $by$ have the same remainder after division by $p$.  Thus $$p|bx-by=b(x-y).$$  As $p\nmid b$, we must have that $p|x-y$.  However as $x,y$ were both picked from $S$, they cannot differ by $p$ or more, so $x=y$.
Thus $f$ is injective.  As $f$ is a map from the finite set $S$ to itself, it must also be surjective (by the pigeonhole principle).  Thus $f$ is a bijection.
Let $u$ be the remainder of $a^2$ after division by $p$.
There is a unique $c\in S$, such that $f(c)=u$.  In other words there is a unique $c\in S$ such that $bc$ and $a^2$ have the same remainder left, after they are both divided by $p$.
The numbers $a^2,bc$ having the same remainder after division by $p$, is the same as $p|a^2-bc$.
