I know it learns to recognise viruses by making antibodies, so that the next time the same virus is seen it can react quickly. Does something similar happen for bacteria?
There are bacterins, vaccines against bacterial organisms. An example is the Bordatella Bacterin dogs are often required to have in order to be boarded in a kennel.
Yes. And there are vaccines that count on that. Despite the name, Haemophilus influenzae is a bacterium and there is a routine human vaccine against Hib infections.
For bacterial infections we also have antibiotic treatments as another line of defense, so in very general terms perhaps you could say that vaccines against virusal disease are more important. There are more of them. But there are several important vaccines against bacterial infection, here’s a list:
In general terms the vaccines work in a similar way. An exception is the Diphtheria & Tetanus vaccines, which protect against the toxins produced by the bacteria, rather than the organism itself.