DNA mutations happen randomly during division by mitosis. Some of these mutations code for antibiotic resistance. When a bacterial colony is exposed to antibiotics most bacteria without the resistance mutation will die - the antibiotics are a selection pressure. As a result, the bacteria with antibiotic resistence have a higher chance of surviving and dividing to create offspring. Over many generations, antibiotic resistance mutation will become more and more frequent - this is directional selection.