Some drones do have cameras which have fixed focus lenses which makes this a non-issue, but those cameras that do have adjustable focus must be used with care. The rule of thumb is to always use manual focus. Set the focus on the scanned object or terrain and then turn the manual focus mode on, so that the focus will not change between images.
If the distance between the object or terrain and the camera is extremely variable, first the flight plan should be adjusted and if that is not possible autofocus can be used.