I would take your kitty to the vet to make sure everything is working properly and he is not sick. Or at least call the vet and explain your situation and see what they say to do.
Sounds like anal glands. They are normally expressed when your cat has a bowel movement but can express spotaneously if they are full. You can have your vet express them on a regular basis to prevent "surprises" or get him/her to show you how to do it yourself. (Most people opt for the forst option
) If you notice your cat "scooting" or licking his/her bum obsessively you might want to get it looked at as they can become impacted and infected.