Towardsthe last days of the mating period, all you need is one moment of being off guard for your female dog to have an unwanted encounter with a male dog. Unlike humans (almost), dogs can mate anywhere and everywhere, which means you have a good chance of catching your dog "in fraganti" in that precise moment. Now, if you arrive at the scene too late, do not try to separate them - no buckets of water, no slaps, none of that! That would be hurting them, and, besides, it would be useless because the insemination has already taken place. Don't get to close to the, in this case, unfriendly couple because you might get bitten. Simply make an appointment with your veterinarian. The dog can receive, for example, her first injection within the first three days; then she will receive another two.
Important: The injections prolong the mating period. You should, therefore, keep an eye on her for a longer time and fix any glitch in your "surveillance system".