Contractile vacuoles in bacteria function to pump excess water out of the cell, helping to regulate the cell's internal water balance. This process is crucial for maintaining the cell's osmotic pressure and preventing it from bursting due to excessive water intake.