To show that the solutions of $x^2\equiv 1\pmod{p}$ are $x\equiv \pm 1$ actually requires that we prove two things.
We must show that (i) $x\equiv 1\pmod{p}$ is a solution, and $x\equiv -1\pmod{p}$ is a solution.
We must also show that (ii) there are no other solutions modulo $p$.
Proving (i) is easy. All we need to do is to verify that $(1)^2\equiv 1\pmod{p}$ and $(-1)^2\equiv 1 \pmod{p}$.
Note that if $p=2$ the two solutions are the same. For $1\equiv -1\pmod{2}$.
We now turn to the proof of (ii). We know that if $x^2\equiv 1\pmod{p}$, then $p$ divides $x^2-1$, and therefore $p$ divides $(x-1)(x+1)$.
Since $p$ is prime, and divides $(x-1)(x+1)$, we must have (a) $p$ divides $x-1$ or (b) $p$ divides $x+1$.
In Cae (a), we have $x\equiv 1\pmod{p}$. In Case (b), we have $x\equiv -1\pmod{p}$. There are no other possibilities.
Remark: Note that if $p$ is composite, then the result can fail. For example, the congruence $x^2\equiv 1\pmod{8}$ has four solutions modulo $8$, namely $x\equiv \pm 1\pmod{8}$, and $x\equiv \pm 3\pmod{8}$.