There are a few reasons that a anal fistula happen. The most common reason is because of an anal abscess.that does not heal properly.
Less common causes of anal fistulas include:
Crohn's disease, diverticulitis, hidradenitis suppurativa, a infection because of tuberculosis (TB) or HIV and possibly a complication of surgery near the anus