Suppose we have two expressions: $\frac{x-1}{x-1}$ and $1$. In the first expression we cancel the nominator and the denominator and are left with $\frac{1}{1} = 1$ and the first two expressions are said to be equal. Now let us define two functions with these two expressions:
$f(x) = \frac{x-1}{x-1}$ and $g(x) = 1$.
The first function is not defined at 1 because we can't divide by zero and its domain is R not including 1. It is still said that we can cancel the nominator and the denominator in the function and get $f(x) = 1 = g(x)$ thus obtaining a function that is equal to $g(x)$. How is this possible when for two functions to be equal their domains must be equal? How can we use them interchangeably when they are two different functions?