How do doctors know what prescription is needed for baby eyeglasses, if babies can't read an eye chart?

Refraction. Refraction is the measurement of how much the eye bends light. Refraction can be performed subjecively - the doctor shows the patient an image through progressively stronger lenses until the patient sees clearly - or objectively, by measuring how reflected light from the eye is bent and using lenses to "straighten" the bend without the patient giving his/her input. This method is used for children.