Thats a prolapsed rectum most likely caused by a heavy parasite load you need to lubricate it with ky jelly and take him to a vet you can try to press it back in gently but I am more comfortable with a vet doing that. If you have a fecal sample from that snake take it to the vet with you. It is very important even if you are able to get it back in to follow up with a vet ASAP.
Keep it lubricated until you are able to seek medical attention for the snake.
Good luck.