Why do dogs lock when mating?

because they get stuck together while in the process due to the male swelling for a few mins.