Doctors have to choose the most appropriate antimicrobial drug to use to treat an infection, if one is needed at all, to try to slow down the development of resistance to antimicrobials. Doctors choose an antimicrobial by know what bug/drug combinations work, i.e. which antimicrobial will work against which bug. If you are given an antibiotic for an infection but it doesn't work, it may be that your infection is not bacterial and that is why the antibiotic is not working.
If you are given antibiotics make sure that you complete the course otherwise you may not get rid of the bacteria and your symptoms may reappear. If your doctor is sure that you have a bacterial infection and that the first antibiotic has not worked, he/she may give you another antibiotic, as the bacteria causing your infection may be resistant to the first antibiotic. It is important to discuss with your doctor all aspects of your treatment so that you can be sure you are not taking an antibiotic unecessarily and that when you do take one you take it exactly as he/she recommends.