Where do the bacteria within the vagina originate from?
Most of the initial colonisation is said to be coincidental ('happenstance' as the textbook puts it!) exposure. 

It's then fairly predictable depending on:


type of delivery (as Larry commented);
feeding; and
receipt of antibiotics.


In terms of feeding, there are differences in flora between babies fed human milk and those that are given cow's milk. 

There's a section called 'Establishment and Composition of Normal Flora' in chapter 187 of Principles and Practice of Pediatric Infectious Diseases (3rd ed) by Long which discusses the above.

It's also said that hormones may influence indigenous flora. For example, premenarcheal and postmenopausal vaginal flora are very different to those present during the childbearing period.[1].


Mandell, Douglas, and Bennett's Principles and Practice of Infectious Diseases. 7th ed. 2009. Churchill Livingstone.