Say for example we have the following function
$$\frac{2x+8}{x^2+x-12}$$ at $-4$ both functions have the same value which is zero which means at this point the functions cross.
How is it that their division at this given point means they must share a common factor and thus can be simpilfied?
Not all such functions can be simplified. Take for example $f(x)=x$ and $g(x)=e^x-1$. Then while both functions have a root at $0$, their ratio $$\frac{f(x)}{g(x)}=\frac{x}{e^x-1}$$ cannot be simplified (without say appealing to a Taylor expansion).
The point is that there is something special about the ratio of polynomials with matching roots. This comes from the factor theorem which states that if $h(x)$ is a polynomial, it has a factor of $(x-a)$ if and only if $h(a)=0$.
So, if $f(x)$ and $g(x)$ are polynomials and they both have a root at $a$, that is $f(a)=g(a)=0$, then we can write $f(x)=(x-a)p(x)$ and $g(x)=(x-a)q(x)$ where $\deg(p(x))<\deg(f(x))$ and $\deg(q(x))<\deg(g(x))$.
Hence we have
$$\frac{f(x)}{g(x)}=\frac{(x-a)p(x)}{(x-a)q(x)}$$
and in particular for $x\ne a$, we can simplify this to
$$\frac{f(x)}{g(x)}=\frac{p(x)}{q(x)}$$
Note that at $x=a$, the ratio $\dfrac{f(x)}{g(x)}$ is undefined.