Antibiotic resistance is the ability of bacteria to resist the effects of antibiotics. This occurs when bacteria change so that the antibiotics no longer affect them, allowing them to survive and reproduce unchecked. Bacteria gain antibiotic resistance in three ways.
Some bacteria gain antibiotic resistance through random mutation. Since these are the bacteria that won't be killed off by the antibiotics, they are the ones left to reproduce and pass that resistance on to their offspring.
Bacteria have the ability to scavenge DNA from the environment. When infecting another organism, the DNA left lying around for the bacteria to absorb can be DNA of the host and DNA from previous bacterial infections. Since there will be traces of the antibiotic, the bacteria killed by that antibiotic, and the immune cells of the host itself, new bacteria can potentially have a lot of resistant genetic material to pass on to their offspring.
Bacteria also have the ability to share their DNA with other bacteria around them. This allows bacteria with antibiotic resistance to give those resistances to the other live bacteria around them.
Many doctors prescribe antibiotics at the first sign of an infection that might be bacterial. Most commercially produced food animals are dosed with antibiotics with each meal to keep infections down in the herds and flocks. Additionally, many hand, bath, laundry, and dish soaps are antibacterial.
This creates an overabundance of antibiotics in the environment. Bacteria can use this to build resistance to antibiotics in the same way we build immunity through vaccines, compounding the effectiveness of the the three methods of evolving