Sequential evolution of bacterial morphology by co-option of a developmental regulator