Also, there's horizontal gene transfer to account for. It further complicates the picture.
https://www.discoverwildlife.com/animal-facts/fish/can-fish-...
Genes get duplicated by accident, then accumulate mutations which are usually neutral or worse. Occasionally they help you achieve something slightly more useful than before. Lobed fins that helped you heave yourself back into water when you get beached would have helped. bigger lobed fins would help you get back when stranded further up the beach, or get from pool to pool. It's unlikely that an entire set of limbs, other necessary body upgrades to support them and neural circuits would just hang around waiting for all the right mutations to collect like hole punches on a restaurant loyalty card before some critter slapped their thighs and stood up and walked. Evolution does not plan ahead.
this is an argument from personal incredulity. just because you are too dumb to understand how something works doesn't mean that your fantasy/sci-fi version is accurate. brains changing genes belongs in a discussion of Neal Asher's polity, not in a biology discussion.
thankfully, nobody is claiming that happens. i can explain more, but there's the issue of my fees. £200,000 seems reasonable, given how dumb you are.
The current best hypothesis is that RNA randomly developed and evolved. Some if it happened to be self-copying. If there are self-copying things, there will be lots of self-copying things - that's common sense. And a genetic algorithm fitness function. In an ocean with RNA, sometimes it will happen to bump into other bits of RNA and swap over. Sometimes they randomly get better at copying. Zillions of molecules and hundreds of millions of years is a long time for small chances to happen. We want genetic algorithms to run in seconds on a PC. Ones that run for millions of years in the Earth's whole ocean don't have to be nearly as good.
The Miller-Urey experiment demonstrated that chemicals we know as building blocks of life can come into existence by themselves in early Earth conditions. What we don't know yet is exactly how they got from there to cells, since we don't have a time machine to go and look. Scientists keep finding plausible stepping stones, though.
Something like "the computational complexity of a beached fish to invent and grow a leg is O(n^2 log n) hours where n is the number of neural spikes in frontal cortex" or similar.