Fingernails are weird. If you think about it, most land-based animals and birds have some manner of fingernail. What we call a fingernail has analogies in dogs and cats (claws), horses and cows (hooves), birds (talons) and even dinosaurs (also claws). That so much of extant life has this mechanism would imply one of two things: an extraordinary amount of convergent evolution across modern species or that all of these wildly disparate species share a single common ancestor who possessed some form of proto-fingernail/proto-claw.
Convergent evolution is a term that describes the process by which unrelated species evolve morphologically similar traits. Think dolphins and sharks. At a glance, they have very similar morphologies (i.e., physical shapes), but the species aren’t even remotely related from a genetic perspective. Two very different lineages of animal, under the same environmental pressures, developed similar body styles. Though highly unlikely, it’s not outside the realm of possibility that cats and dogs evolved morphologically similar claws (the retractability of cat claws notwithstanding), based on similar environmental pressures. Not impossible, but given the scope of animals involved, very highly unlikely.
The more likely explanation is that somewhere back in the dim, dark past of life, we all share a common ancestor that had a fingernail/hoof/claw/talon-type structure. As the lineage of that ancestor split and divergent lines evolved into new species, that proto-fingernail evolved to fill the needs of those animals; who in turn produced new offspring divergent lines of evolution of their own. Before you knew it (that is, if you had a lifespan in the billions of years), that single proto-fingernail had evolved to be a defensive weapon, an offensive weapon, a tool for digging, a tool for grasping, a tool for carrying, an ancillary mechanism for fingertip rigidity, etc. etc.
Like I said. Fingernails are weird.