Phimosis is a condition that causes the foreskin to retract inside the glans of the penis, resulting in difficulty or pain with erection or masturbation. It is common among children, teens, and even adults. The problem with phimosis is that it does not go away on its own. It may get better after puberty, but if left untreated, it will cause damage to the foreskin, which can result in painful erections, increased risk of sexually transmitted diseases, and decreased sexual pleasure. This is why it is important to treat this condition as soon as possible. It may not go away on its own, so treatment is often recommended.
Source: https://gautamclinic.com/treatment/phimosis-treatment
It is possible that the doctor is just not an experienced enough circumciser to get the whole thing off. I have heard that circumcising an infant is a bit more difficult than doing so on an older child. But I think the main thing is to be very patient with him, and let him know that it is ok to be upset about the procedure.