They just factored out ##(x-a)^p## from both the numerator and the denominator (possibly with a different value of ##p## for the numerator and denominator.) Let ##p_1 = p_{\text{numerator}}## and ##p_2 = p_{\text{denominator}}##.
(1) If ##p_1 = p_2## then all factors ##(x-a)## cancel out completely, and you are left with a fraction of the form ##f_1(x)/g_1(x)##, where neither ##f_1## nor ##g_1## vanishes at ##x = a##---so you get a finite, nonzero limit.
(2) If ##p_1 > p_2## your fraction simplifies to ##(x-a)^{p_1 - p_2} \times f_1(x)/g_1(x)##, where neither ##f_1## nor ##f_2## vanishes at ##x = a##. Therefore, the limit is ##0##, because ##(x-a)^{p_1 - p_2 } \to 0.##
(3) If ##p_1 < p_2## the fraction simplifies to ##f_1(x)/f_2(x) \times 1/(x-a)^{p_2 - p_1}##. Since ##1/(x-a)^{p_2 - p_1} \to \pm \infty##, the limit does not exist.