Prevention: Bacterial infections can happen for many reasons, but bad water quality is a happy environment for bacteria to grow in. Contact with dead fish can spread them too, though your bettas shouldn't have that problem unless they're in a community tank.
Symptoms: Betta may have clamped fins, lay at bottom or at surface, not eat, lose its color, turn gray, barely swim around. In more advanced cases, its body may
start developing red patches, open sores and all kinds of nasty looking stuff. Different bacteria affect fish differently. Some will attack the internal organs while others prefer to munch on the skin.
Treatment: The term "bacterial infection" is very broad, and so you'll have to treat a side range of possible infections. Do a full water change. Clean filter and filtering system if you have them and remove any uneaten food rotting. Isolate any bettas with symptoms if in a community tank.
You should also treat the whole tank. There is a wide variety of antibiotics available for fish. Remove carbon from your filters before you add the medications: the carbon would otherwise absorb all the medication. Use Tetracycline or Ampicillin combined with Fungus Eliminator or whatever you find at your store (look for “broad spectrum” antibiotics, though a good one is Kanamycin if you can find some). You can learn more about all of these in the First Aid section. Follow manufacturer’s instructions and don’t stop the treatment until your bettas are well again. Dose carefully and to the correct proportions, and you'll have to redose after you do water changes, which you should do every three days or so.