Horizontal gene transfer mechanism allows bacteria to acquire genes responsible for Anti-Microbial Resistance. But what benefit that the donor bacteria gets? and Why do they do?
Plasmids and other so-called selfish DNA are called such because theirs is not the interest of the microbe but rather maintenance and propagation. Bacteria have evolved elaborate systems to keep foreign DNA out of them but these are circumvented by the mediators of HGT. Serendipity plays a large role.