The first, and by far most important is that unlike ground meat, your bacterial concerns are almost entirely on the surface. Unless something very very very wrong has occurred in the processing and transport chain, bacteria will not have penetrated into the meat. And if it's gotten bad enough that they have, you will almost certainly be able to see and smell it. And the surface is cooked to a temperature far in excess of that needed to kill bacteria.
And even for the interior, rare is not the same as raw. A completely rare steak should be cooked to between 120 and 130 (if you want it "blue" you might go down to 120). That's enough to get a decent reduction in bacterial count on it's own, although admittedly many techniques will not hold it long enough to get the number of log reductions that food safety guidelines recommend, in the case that you somehow did have a large bacterial infection in the interior.
So the answer to your question is that if you are buying your meat from an even halfway reputable source, the only place that bacteria might exist is on the surface, where it has been cut by tools and handled by the butcher/you and in general come into contact with the world. Those bacteria will be 100% killed by the cooking process. The odds of getting sick from a rare steak are low enough that if you are concerned about that, there are innumerable other things in your life that you should be more concerned by.
This way undersells what's actually happening: fecal matter from the intestines gets onto your meat. This shouldn't happen with proper practices.
In the case of steaks, bacteria is only on the outside (they can't penetrate the muscle) so the sear makes it safe to eat somewhat raw on the inside.