Some bacteria is actually good for you while other bacterial infections are bad for you and are contagious so it would depend on what type of bacterial infection you're talking about.
If it's a bacterial lung or throat infection then yes the bacterial infection is contagious and you should avoid being around anyone with a bacterial lung or throat infection and wear a mask if you have to be around them.