I'm looking at an example in my book. I have the following equation:

My book manages to simplify it to:

How did it do this? I see that x^2 is in the denominator, I understand that it would cancel out and leave us with 5. But I assumed that after that, the equation would look like this:

which equals

Which is incorrect. But I don't see why...