I got out of diapers at a normal age the first time around (3-ish, I think) but continued to have frequent accidents through elementary school. In retrospect, I'm not entirely sure why–partly, I think it was a nervous thing about being afraid to use public bathrooms but partly I remember having problems starting to leak on myself a little as soon as I really knew I needed to go.
My parents put up with it without that big of a fuss until after my little brother was born, around when I was finishing the 1st grade. After that, I guess the stress of a new kid wore their patience thin, and my mom started threatening to put me in my brother's diapers if I kept doing it. (In retrospect, this was probably just a scare tactic at first? I wouldn't even have fit in them, probably. But little kid me took it 100% seriously.) Unfortunately, that made me get better about hiding my wet clothes when I had accidents but not so much about actually avoiding then.
So, middle of 4th grade, my little bro is almost potty-trained, and my mom gets called to school to bring me a change of pants. She goes to get clean underwear from my dresser and finds like half of the pairs there are stained from where I'd stashed them in the back of the drawer after accidents.
Cue 9 year-old me having a crying fit in front of the school nurse, after my mom showed up with a pack of Pull-Ups instead of my underoos.
I ultimately ended up wearing Goodnites to school after that up until the 8th grade, with only occasional breaks in between. At a couple points mom got me full-on youth diapers, but they only really got used for bed/long trips.