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.
Also, there's horizontal gene transfer to account for. It further complicates the picture.