There's no set age that a kid has to be potty trained since all kids potty train at different ages.
In the early days including my time kids were potty trained and out of diapers by age 18 months old.
My mom told me that I was potty trained at 18 months of age but some kids today are not ready to potty train until at least 2 and some aren't potty trained until 4 years old.
A kid should at least begin potty training at 3 years old at the latest and be out of diapers by 4 years old unless the child has some other disability or bladder problem that prevents them from being potty trained.
Preschools won't change diapers and kids will need to be out of diapers for kindergarten as well.