Ornate bichir with a bacterial infection
Under normal circumstances the bacteria live in the background and don't bother any healthy fish which could easily fight off a minor bacterial infection. But in a crowded aquarium where the water quality isn't as good as it might be and the fish are under some stress they are less able to fight off opportunistic infections and once one fish is infected the bacteria have a host and will multiply rapidly above normal background levels. When this happens they are able to overwhelm the defences of other fish more easily, particularly if those fish are under some stress.
Some infections can be introduced with new livestock and if the new fish are added straight to the tank the infection can spread, using a small quarantine tank would avoid this. Most other bacterial infections can be attributed to keeping fish either in poor conditions or in the wrong conditions for that species due to the stress caused by either condition.
Keeping fish in well maintained conditions and in the right environment usually means there will be very few health problems.
There are lots of potential giveaways when looking for a bacterial infection.
Many of the above may have other causes so it is best not to assume anything, and never treat any health problem without a proper diagnosis.
Early diagnosis and treatment offers the best chance of a good outcome. Over the counter antibacterial products work quite well in the early stages of an infection but established infections may need treating with antibiotics.
Bacteria live in the aquarium environment all the time they do a great job in helping to breakdown any organic waste in to relatively harmless nitrate keeping the water from becoming toxic to the fish in doing so. It would be almost impossible to keep fish without these bacteria being present.