Superinfection exclusion factors drive a history-dependent switch from vertical to horizontal phage transmission.