If f(x) is of degree n and g(x) is of degree m, then f(x)/g(x) is a polynomial of degree n - m with some fractional remainder that is negligable since it will go to 0.

If n > m, then n - m > 0. Any positive degree polynomial will go to positive or negative infinity when x goes to infinity.

If n < m, then n - m < 0. Any negative degree polynomial will go to 0 when x goes to infinity.

If n = m, then n - m = 0, which means the quotient will be a constant. The limit of a constant is a constant.

So the only way to get a nonzero constant as the limit is to have f(x) and g(x) have the same degree.