It's hard to express your idea with mathematical precision. To put your question in a sophisticated way: When does a function that is the ratio of polynomial factors have a "removable singularity"? You want to know when an otherwise solid graph of a function has a hole at a (finite) point (x,y).
One can define funtions in complicated ways using if...then rules as well as algebraic expressions. Suppose we only consider a function defined by the ratio of polynomial factors. (i.e. its is a single fraction , not a sum of several fractions).
Functions like f(x) =\frac{(x^2 + 1) (2x + 3)} { (x^2 + 1)} don't have a hole in their graph because (in the real number system) there is no value of x that would make the denominator zero. So the fact that the numerator and denominator have a common factor does not always imply the function has a hole in its graph. Looking for terms that cancel out, doesn't automatically locate a hole in the graph.
By contrast, the graph of the function g(x) = \frac{(x^2 -1 )(2x + 3)}{(x^2 - 1) } has a holes when x = 1 and x = -1.
The graph of the function h(x) = \frac{ 6 + (x^2 )}{(x^2-1) } doesn't exist at the values x = 1 and x = -1 because those values make the denominator zero. Since x^2 -1 is not a common factor, the fraction cannot be reduced. The graph does not have a hole at any finite point (x,y). Values of x that make the denominator zero cause the graph not to exist, even if there are no common factors in the fraction.