Explain how limbless salamanders evolved ?

Salamanders don't need legs in order to swim; therefore the limbs aren't necessary and gradually -- over hundreds of generations -- withered away because they were a hindrance to swimming.