Young chicks sometimes get a bit of a rectal prolapse as a result of constipation. Probably this happens when they have spilled their water or clogged it up with shavings, or eaten a bit too many shavings, or something of this sort. I'd put a little hemorrhoid ointment on it, if you have any, or just some Vaseline or olive oil. Of course, make sure it has fresh water at all times. If you have some molasses or organic apple cider vinegar, put maybe a tbsp in a gallon of drinking water. I'd moisten a bit of its feed and give this maybe twice a day (remove any it doesn't eat.) I'd also give it a bit of probiotics, maybe mix a bit of yogurt or buttermilk into some feed and give that. You need to separate the chick so others don't peck at its behind. Also, be very sure the chicks are not too hot, which can dehydrate them quickly. You might have to put the water higher up to keep it from filling with shavings, if that's what is happening.
I don't know what you'd do about its pecking itself, unless you can rig up a collar, similar to those cone shaped collars vets put on dogs.