Phage–host population dynamics promotes prophage acquisition in bacteria with innate immunity