Suppose we have a limit: $$ \lim_{x\rightarrow 1}\frac{x-1}{x^2-1}=\lim_{x\rightarrow 1}\frac{x-1}{(x-1)(x+1)}=\lim_{x\rightarrow 1}\frac{1}{x+1}=0.5 $$ Here we can cut $(x-1)$ because $x\rightarrow 1$ so $x\neq 1$ and $(x-1)\neq 0$.
When in general can we cut same terms in the numerator and the denominator (in limits, in equations etc) and when we can't?