Is taking modulus on both sides of an equation valid?
The problem is, "taking-mod-of-both-sides" is valid, but only gives a one way implication. If $z_{1} = z_{2}$ then $|z_{1}| = |z_{2}|$. But there are lots of possibilities for $z_{3}$,$z_{4}$ with $|z_{3}| = |z_{4}|$ and $z_{3} \neq z_{4}$, since modulus is not a one-to-one map.
When you look at ${\left(\frac{1+\mathrm{i}}{1-\mathrm{i}}\right)}^{n}$, this always has modulus $1$ for all values of $n$. But this just means it lies on the unit circle in the complex plane, it does not mean that it is equal to 1.
I'm sure you have learned that when solving equations, if you square both sides you can introduce spurious solutions. The point is that $$A = B \implies A^2 = B^2 $$ but the converse can fail. That's why we teach algebra students to check their answers back in the original equation.
Taking the modulus on both sides of the equation has the same effect: $$A = B \implies |A| = |B| $$ but the converse can fail, for example $|i|=|1|$ but $i \ne 1$.
When you took the modulus on both sides of your equation, you introduced spurious solutions. So you have to check each solution to see if it satisfies the original equation.