The long, black thing coming out is your turtle's penis (absolute proof you have a male).

It's called fanning and males do it occasionally as a matter of course. As long as it goes right back in, it's OK. I'm wondering, though, if he does it absolutely every time he poops. Does he?
As you sure he's not eating his poop?
Turtles can become constipated, and often indicate this by kicking at their butts/tails with their hind legs. Is your turtle doing this that you've noticed?
"You become responsible, forever, for what you have tamed." -Antoine de Saint Exupery-