Cooperative virulence can emerge via horizontal gene transfer but is stabilized by transmission