I know that what I write is not an answer to your question, but I recommend strongly thinking of congruence modulo $p$ as an equivalence relation, and not thinking of “mod” as a function that you apply to numbers.
So we write $a\equiv b\pmod p$ to mean no more and no less than that $b-a$ is a multiple of $p$, or as we like to write, $p|(b-a)$. Then congruence modulo $p$ behaves like equality but isn’t: you have $a\equiv a\pmod p$; if $a\equiv b\pmod p$ then $b\equiv a\pmod p$; and if both $a\equiv b\pmod p$ and $b\equiv c\pmod p$, then $a\equiv c\pmod p$.
Then you show easily enough that if $a\equiv a'\pmod p$ and $b\equiv b'\pmod p$, then $a+b\equiv a'+b'\pmod p$, and you also get $ab\equiv a'b'\pmod p$. These mean that congruence modulo $p$ respects addition and multiplication, so that if you’re only interested in what some messy expression turns out to be modulo $p$, you can replace the ingredients by things congruent to them, not only at the initial stage of your computation, but at any stage you want. Want to know the final decimal digit of $17^{50}$? That’s asking for the congruence of $17^{50}$ modulo $10$. You see that $17^0=1\equiv1\pmod{10}$, $17^1=17\equiv7\pmod{10}$, $17^2\equiv7^2=49\equiv-1\pmod{10}$, and $17^3\equiv7^3=7^2\cdot7\equiv-1\cdot7=-7\pmod{10}$, and finally $7^4=(7^2)^2\equiv(-1)^2=1\pmod{10}$, and from then on, they cycle through $1,7,-1,-7$ repeatedly. So you see that $17^{50}\equiv17^2\equiv-1\equiv9\pmod{10}$, and the final digit of $17^{50}$ is $9$.
Note that I was scrupulous in writing congruence (\equiv) when things were merely congruent, and equality ($=$) when things were equal. Note also that I never did subtractions, just replaced things by other things congruent to them whenever I felt like it.