Hi, I am Dr. Peter and would like to help.
1- Is he penis sticking out of the prepuce and does not go back in?
2- How long has this been going on?
This is actually is an emergency because his penis can suffer irreversible damage and in some cases if very badly damage needs to be amputed. He does not have an erection; what is happening is that the orifice of his prepuce is too small in relation to his penis and he cannot get it back in. The orifice needs to be surgically open or this will continue to reoccur. For now, what you can do is get some lube or vaseline and try to pull the prepuce over his penis to get back inside. May apply cold compresses to decrease the size of the vessels and see if becomes smaller. If you can not do this, take him to ER vet to have this done and surgically enlarge the prepuce orifice.
If you have additional questions I will be glad to answer them.