How does a male dog get stuck to a female dog during mating?

Mating is a relatively brief process; they mate, and then they separate. They do not get stuck.