Dear student.
There are two ways which could be the origin of microbes in interplanetary space.
1. Few bacteria are released into space for research purpose in order to check their survival capacity.
2. Transferred into space through the contamination or infection of humans, those who are present in space.
There is no information present regarding the presence of bacteria in comets.
Regards.