One of my pet peeves is the common description in the media of bacteria "learning" to "outsmart" antibiotics. As anyone with a basic comprehension of evolution knows, learning has nothing to do with it. Learning is what happens during the lifetime of an individual, and it occurs in direct response to some information that the individual encounters. When bacteria become resistant to antibiotics, it is not by learning. The individual bacteria do not sense the antibiotic and change to become resistant. Rather, individual bacteria in a population that happen to be resistant because of some genetic difference (or in whom a mutation conferring resistance arises by chance or through gene transfer from another population) will survive and reproduce more effectively than individuals lacking the genetic characteristic that confers resistance.
Over many generations of this process, the gene providing resistance to the antibiotic will be found in the majority of bacteria -- not because it "spreads" and not because individual bacteria develop resistance, but because the bacteria that are the most abundant in the population after many generations are obviously the descendants of the ancestors that left the most offspring, namely those who survived the antibiotics.