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 [itex]f(x) =\frac{(x^2 + 1) (2x + 3)} { (x^2 + 1)}[/itex] don't have a hole in their graph because (in the real number system) there is no value of [itex]x[/itex] 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 [itex]g(x) = \frac{(x^2 -1 )(2x + 3)}{(x^2 - 1) }[/itex] has a holes when [itex]x = 1[/itex] and [itex]x = -1[/itex].
The graph of the function [itex]h(x) = \frac{ 6 + (x^2 )}{(x^2-1) }[/itex] doesn't exist at the values [itex]x = 1[/itex] and [itex]x = -1[/itex] because those values make the denominator zero. Since [itex]x^2 -1[/itex] 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 [itex]x[/itex] that make the denominator zero cause the graph not to exist, even if there are no common factors in the fraction.