Why does my dog get stuck to the female after mating?
The males penis will swell inside the females vagina during the mating. This will cause them to get stuck. It is completely normal for dogs to get stuck together after mating and you should not attempt to divide them. If you don't want them to mate you should have had enough time to try separating them before.
Our non-neutered female dog mated with our castrated male a few times. Especially during the first few times we had to secure them, as she got very excited after the mating. She tried to run away and this caused or male incredible pain. I held her by her chest/neck area so she could not run away any longer and waited until they separated on their own.
The time it takes for the swelling to reduce and allow separation differs, one article on the breeding tie suggests a time between 2 and 30 minutes. I quote some other information from the article I think is noteworthy:
Getting stuck together is normal. Do NOT ice them to get them apart. […]
It is advised that you give close supervision and keep them calm. […] You do not want the female to panic and start squirming. If she is larger than the male she can really hurt the male. He is helpless and will usually stand perfectly still, waiting. […]
After a tie […] check your male, and make sure that his penis has gone back inside of him and is not strangled in hair or stuck out.
Note that the article is about breeding, thus I removed information that does not relate to your question about mating.