In newborns, often there is no apparent reason — it could just be the air hitting their genitals when you change them, or perhaps their bladder is full, and they need to urinate. However, no one wants to see this at the dinner table or the park either. Not all little boys find erections pleasurable. Some kids are frightened by the change in their penis or find it uncomfortable or painful, especially if the erection is quite strong and lasts for a while. Most erections are normal and harmless in children and go down by themselves fairly quickly with no issues. However, there are a few instances when it might be something more serious.
Everything you wanted to know about little boys and their erections
Erection - Wikipedia
An erection clinically: penile erection or penile tumescence is a physiological phenomenon in which the penis becomes firm, engorged, and enlarged. Penile erection is the result of a complex interaction of psychological, neural, vascular, and endocrine factors, and is often associated with sexual arousal or sexual attraction , although erections can also be spontaneous. The shape, angle, and direction of an erection varies considerably in humans. Physiologically, erection is triggered by the parasympathetic division of the autonomic nervous system , causing the levels of nitric oxide a vasodilator to rise in the trabecular arteries and smooth muscle of the penis. The arteries dilate causing the corpora cavernosa of the penis and to a lesser extent the corpus spongiosum to fill with blood ; simultaneously the ischiocavernosus and bulbospongiosus muscles compress the veins of the corpora cavernosa restricting the egress and circulation of this blood. Erection subsides when parasympathetic activity reduces to baseline.