Unconstrained use of antibiotics allow bacteria's natural defenses to learn how to stay alive in our bodies.
A bacterium does a series of chemical transformations to stay alive.
An antibiotic disrupts the bacteria lifecycle by interfering with such transformations.
These transformations might be different across bacteria. As you have millions of bacteria in an individual, some might suffer smaller results from the antibiotic, and be 'not as disrupted'.
If you don't take the full dose of antibiotics, these 'not as disrupted' bacteria might survive, make you sick again. And worse: the antibiotic will have a harder time killing them.
Some of their 'children' will be more 'disruptable' then they are, some less, but the average is less 'disruptable'.
Repeat the process many times, and you get bacteria that don't die with the antibiotic :(
Nothing to do with your immune system, that creates its own kind of 'antibiotic'
If there are you could attack it with a coctail of two or three.