Suppose I have this:
$\frac{6^{666}}{2^{6}}$ (mod $125$)
I saw it is possible to reduce only the numerator's power modulo Euler's phi function. Can someone explain why is that possible?
It is essentially this:
$\frac{6^{666 \space (mod \phi(125))}}{2^{6}}$ (mod $125$)
It is valid to mod out arguments of a fraction - just like it is for the arguments sums and products
Lemma $ $ If $\,(B,n)= 1\,$ then $\bmod n\!:\,\ \begin{align}A&\equiv a\\ B&\equiv b\end{align}\,\Rightarrow\, \dfrac{A}B\,\equiv\, \dfrac{a}b,\:$ i.e. $\,A \color{#c00}{B^{-1}}\equiv a\color{#c00}{b^{-1}}$
Proof $\ \ $ Scaling $\: b\equiv B\:$ by $\:b^{-1}B^{-1}\Rightarrow \color{#c00}{B^{-1}\equiv b^{-1}}\,$ by CPR = Congruence Product Rule, so multiplying that by $\, A\equiv a\, $ we obtain $\, A\color{#c00}{B^{-1}}\equiv a\color{#c00}{b^{-1}}$ again by CPR. $ $ Note $b^{-1}$ exists since $\,b\equiv B\pmod{\!n}\Rightarrow (b,n) = (B,n)=1\,$ by gcd mod reduction.
Thus the answer to your question as to "why it works" is that unwinding the definition of a fraction yields a composition of a product and inverse operation - and those operations are "compatible" with modular arithmetic (by Product and Inverse Congruence Rules) hence so too is their composition (modular "division" by units = invertibles = integers $B$ coprime to the modulus).
Similarly the Polynomial Congruence Rule extends to polynomial fractions (rational "functions") or to any expression composed of sum, product, and inverse operations (where the inverses all exist) by a simple inductive proof.
See this answer for much further discussion.