How did fish grow legs?
Try posting it in science, more people there are better qualified to give you a better response then me but I’ll try. See they didn’t really grow legs, they simply had fins and some used them to move along land for whatever purpose (Mud hole to mud hole perhaps like some fish), and the ones that could travel further better survived better, and so the ones who could breathe on land and move quicker reproduced more. This tend continued over many many many years until something resembling legs and lungs developed due to those being less suited dying off more often then those with better “legs” then others.