diffusion .
if the concentration of oxygen in the bacteria is low, oxygen diffuse into it. while carbon dioxide diffuse out.
That's what is prokaryotae
bacteria like any other living organism needs oxygen for its development and metabolism .. so the bacteria ( if it is aerobic) will normally be found in places where there plenty of oxygen for its growth .. and this can be anywhere from earth (ground/soil) to even living inside another cell .. it takes oxygen by diffusion
Because O2 is small, it can diffuse passively through the cell wall and cytoplasmic membrane; random thermal agitation will move it from higher concentration to lower concentration.