The textbook picture of evolution is vertical: a beneficial mutation appears, its carrier reproduces more successfully, and the trait spreads down the generations. For antibiotic resistance, that is only part of the story, and not the fast part.
Horizontal gene transfer
Bacteria carry small circular loops of DNA called plasmids, separate from the main chromosome. Plasmids replicate independently and can be passed directly from one cell to another through a physical bridge, in a process called conjugation. Resistance genes frequently sit on them.
That means a resistance gene can move between two living cells in minutes, without either of them dividing. It can also move between species — from a harmless gut bacterium to a pathogen sharing the same intestine.
Why plasmids accumulate resistance
Many plasmids carry not one resistance gene but a cassette of several, along with genetic elements that capture and insert new ones. Exposure to any single antibiotic in the set selects for cells that keep the whole plasmid, and therefore preserves resistance to the other drugs at the same time. This is how multidrug resistance can appear without exposure to each drug individually.
Where the selection pressure comes from
Any environment where bacteria meet sub-lethal antibiotic concentrations favours resistant cells: incomplete courses of treatment, routine use in livestock, and pharmaceutical and hospital wastewater. The gut of a treated patient or animal is a particularly efficient mixing vessel, holding a dense and diverse bacterial population under drug pressure.
The practical consequence is that resistance is not confined to the species being treated, and does not stay where it arises.

