Genetic origin and evolutionary recycling
The fingers did not appear on an entirely new genetic basis, but originate from the "co-option" of an ancient region of the fish genome, originally involved in the formation of the cloaca (the terminal organ of the digestive, excretory and reproductive systems).
This region of the genome, known as the "regulatory landscape", controls the activation of Hox genes, the "architect genes" that determine where and how body segments are formed.
By studying and editing the fish genome, the scientists noticed that targeted deletion of this landscape regulator results in loss of expression in the cloaca, but not in the fins. This indicates that this mechanism, present in fish, has been reused in terrestrial vertebrates to generate fingers.
What they have in common: fingers and cloaca are terminal structures (end of limbs or organs), due to this evolutionary recycling, according to the study published in Nature.

Fossils: evidence of transition
Fossil fishes 380 million years old, such as Elpistostege watsoni and other sarcopterygians, already show "fingers" (phalanges) inside their fins.
These primitive fingers would have been used to support the weight of the fish in shallow water or on short trips out of the water, giving greater flexibility and support âeuros a decisive step towards conquering dry land.
The first tetrapods (Ichthyostega, Acanthostega) had limbs with 7 to 8 fingers that still resembled swimming fins.
Summary
The appearance of fingers is therefore not a surgical "invention" with land, but the result of evolutionary recycling of an ancestral genomic region, initially used for the termination of other structures, such as the cloaca. This detour of function, combined with the structuring of limbs in flesh-finned fish, enabled our distant ancestors to gradually adapt to life on land.

This result illustrates the ingenuity of evolution: rather than creating from scratch, it constantly recycles and adapts the existing to meet new needs.