My flight was delayed and then canceled because there were problems with the plane.

Why don't airlines have backup planes just in case there're mechanical problems with the plane? Or they do have them, but they just don't use them in these cases for some reason?