Yes these two samples were incorrect because to get the result wrong operations have to be done and the complex number properties were not respected sqrt(-1) = i ...
but still in mathematics we can by taking it in other way (from the result) proof that an incorrect statement is correct here is an exemple I remember from my teacher at school.
Some one asked to a mathematician : "Do you admit that if 2 + 2 = 5 , then we can deduct that you are the pope?." "For sure the mathematician replied, think about that. if we suppose that 2 + 2 = 5. By doing -2 on each side we got 2 = 3. By symmetry we know that 3 = 2 if we do -1 on each side we then got 2 = 1. The pope and me are two but as 2 = 1, then the pope and myself are only one. So we can conclude that I am the pope ! "
This property is called ex-falso quodlibet and says that if a statement is false and true then all other statement is true...
If one day you prove that 0 = 1, as you know that 0 <> 1 then you can deduct using a proof by contradiction that whatever mathematics theorem you can imagine are true. So this will be the end of all the nice theorem that many mathematician has found.
By the way I am not the pope, are you ?