So, the attachments between the foreskin and the penis wear away gradually (much like the hymen/vaginal corona of the vulva does, just far more quickly). The pace at which they do that determines when someone is able to retract their foreskin. For 90% of people with penises, the foreskin mostly loosens and becomes moveable around age two, but this process can take five or more years for others. Sometimes, the foreskin doesn't retract completely until even later, though. Does that help clarify things?
If someone is in adulthood and finds their foreskin is still very tight, and that the tightness is causing them a lot of pain or discomfort, the first step is to talk with a healthcare provider about their options. Often, a steroid cream and gentle stretching exercises are used to loosen the foreskin up. You can read more about that here: A Foreskin Foray: Questions, Concerns, & Clarifications