It's strange but true that there's really no such thing as fish! Unlike with mammals and birds, not all the animals we call fish - aquatic, vertebrate animals covered with scales - descend from the same common ancestor. Put another way, if we go back to the most recent common ancestor of everything we now call fish, we find that it was also the ancestor of all four-legged, land vertebrates (tetrapods), which obviously aren't fish at all.

A detailed view of a branch of the tree of life highlighting the
evolutionary relationship between Classes of fish and the tetrapods.

Biologists call this a paraphyletic collection of taxa, which in the case of fish includes hagfish, lampreys, sharks and rays, ray-finned fish, coelacanths and lungfish. Indeed, lungfish and coelacanths are more closely related to the tetrapods (mammals, birds, amphibians etc) than to fish such as ray-finned fish or sharks.