likephysics said:
Say for example, a fish trying to get out of water eventually grew legs or something resembling legs. What exactly caused the legs to grow and what is this type of mutation called.
Strictly speaking, the fish isn't
trying to get out of water and nature's not
trying to evolve. Nobody knows the exact story of how the leg was 'invented' by fish, it's a good research topic that would probably shed light on evolution in general (particularly with respect to the singularity step of evolution: from one species to another) if we really understood it completely.
Essentially, several random mutation happen all the time that cause some abnormal morphogenesis (i.e. some random bump grows where's it doesn't generally grow in this species, due specifically to an incorrect coding scheme (it has to be passable to offspring, not just a random growth mutation, but something in the actual instruction set pertaining to morphogenesis).
But then to actually have legs is a huge step, needing proper muscle growth, a neural control/sensor system, and if the fish is going to go onto land, it will also need lungs (which some fish do have today, even without legs, so this was a "stable assembly" that still exists; I don't know of any legged fish though and I'm not an evolution expert by any means, but i work for some!).
Fish that grew legs most likely lost their ability to swim (having both could be a disadvantage, each weighing the other down and getting in the way in the wrong environment). The frog displays this kind of metamorphosis in its developmental period, going from tadpole to frog. Not surprisingly, the frog also goes from using buccal (homologous to the fish gill) to using lung as it transitions from tadpole to adult.
So studying the development of the frog is one of the first places to look for clues on how legs might have evolved, though we know now that primitive fish 'invented' the lung.