The similarity is a coincidence; these words are unrelated. Etymological dictionaries such as [De Vaan's](http://www.brill.com/etymological-dictionary-latin) give the following account of the two words: The earlier form of the conjunction *cum* is *quom*; this is attested in early Latin, and also in the word *quoniam* (< *quom iam*). It is descended from Proto-Indo-European *kʷom "when" and has cognates in other IE languages, including English *when*. The earlier form of the preposition *cum* is *com*, which remains its form in compounds (*com-*). This is from PIE *ḱom* "with", which also has reflexes in other languages, including the Germanic verbal prefix *ge-*. The Italic cognates suffice to show that the first sound of the conjunction was a labiovelar (Umbrian **pumpe** "whenever", with *p* from *kʷ*) but the first sound of the preposition was a velar (Umbrian **kum-**).