Understand what? That you have to factor them? As Janhaa said, that's not true- there are other methods. Of course, you cannot just set x= 3 because that gives 0/0 which has no meaning.
That you can factor them? That's due to a fundamental algebra rule: a polynomial is 0 for x= a if and only if it has x- a as a factor.
Here, because setting x= 3 the numerator becomes [tex]3^2+ 2(3)- 15= 0[/tex] so we know that x- 3 is a factor. And since 3(a)= -15, requires that a= -5, we know that the other factor must be x- (-5)= x+ 5:
[tex]x^2+ 2x- 15= (x- 3)(x+ 5)[/tex].
At x= 3, the denominator becomes [tex]3^2- 5(3)+ 6= 0[/tex] so we know that x- 3 is a factor of this also. and since 3(a)= 6 requires that a= 2, we know the other factor must be x- 2:
[tex]x^2-5x+ 6= (x- 2)(x- 3)[/tex].
Then the fraction is [tex]\frac{x^2+ 2x- 15}{x^2- 5x+ 6}= \frac{(x- 3)(x+ 5)}{(x- 3)(x- 2)}[/tex]
Now, as long as x is NOT 3[/tex], we can cancel those terms to get [tex]\frac{x+ 5}{x- 2}[/tex] and setting x= 3 in that we have [tex]\frac{3+ 5}{3- 2}= 8[/tex] which tells us that [tex]\lim_{x\to 3}\frac{x^2+ 2x- 15}{x^2- 5x+ 6}= 8[/tex].
Notice I said "as long as x is NOT 3". We cannot divide by 0 so that reduction is NOT true for x= 3. AT x= 3, this function is not defined- it has no value. But there is a theorem (unfortunately, often overlooked in introductory courses) that says "if f(x)= g(x) in some neighborhood of a but NOT necessarily at x= a (what is called a "deleted neighborhood) then [tex]\lim_{x\to a}f(x)= \lim_{x\to a}g(x)[/tex]".