Many bacteria contain small circular DNA molecules called plasmids in addition to their main chromosome. A plasmid may carry a gene that gives its host a useful trait in a particular environment, such as resistance to an antibiotic. It can be copied within a cell, and some plasmids can move between bacteria.
This is one route by which genetic traits can spread without waiting for a bacterium’s descendants alone. The details depend on the plasmid and organism; carrying a plasmid does not mean every bacterium has the same capability.