This can occur due to anal sac disease. A dog’s anal sacs can become impacted because of inflammation in the ducts. If the sacs are impacted, then the substance secreted from them becomes thicker, which results in swelling.