The point at $z = 1$ is called a "removable singularity", and this process "removes" it. In general, a function having a limit at a point but not defined there can be extended to a function continuous at that point in only one way. That's what happens here. $\frac{z^2 - 1}{z - 1}$ is defined and continuous everywhere except $z = 1$, and has a limit at $z = 1$. $z + 1$ is defined and continuous everywhere, and equals $\frac{z^2 - 1}{z - 1}$ wherever both are defined. So then it must be that unique extension.
NB: It's worth noting that as other posters have pointed out, this equation is not technically correct since one expression is undefined at the point and the other isn't, but the procedure you used gives the unique extension just mentioned.