From history it seems that either you might be having prolapsed internal piles or having fistula in ano.
Consult surgeon and get examined.
Physical examination will give proper clue about your problem.
Meanwhile go for one antibiotic and anti-inflammatory medicine course.
and take plenty of water.
Ok and take care.