Exam done by dr vs being intimate with your partner

Okay so I’ve read a lot about having your dr check you very minimally as it could cause infection. Even when you’re only 1 cm bc you can be 1-3 cm for weeks before going into labour.

But my question is: what’s the difference between getting checked by ur dr, and being intimate with your partner via fingers or penis??? To me it’s the exact same thing, no? Because I’ve been told to have lots of sex up until it just doesn’t feel comfortable anymore. So can sex/fingers give you an infection just like a dr WEARING gloves checkinfnyou increase your chance of infection? I’m confused lol