Evolutionary mechanisms that determine which bacterial genes are carried on plasmids