Self-perpetuating epigenetic pili switches in bacteria