GBS is sometimes diagnosed when swabs are taken during pregnancy - the bacteria would have been there before the pregnancy, as it is often carried in the vagina as a commensal (a bacteria which is normally found in the body).
This is a companion discussion topic for the original article at https://patient.info/pregnancy/strep-b-in-pregnancy