trich In pregnancy

I was told by my obgyn that I had trich while being pregnant and I was treated for it ( I was never told of that when I had it at the time ) which really confused me. She had told me that I had gotten it through sex and that either me or my partner had slept with someone else. I had looked for more information online and saw that it Is common during pregnancy to get it. But would my partner had to have slept with someone else for me to have gotten it?