There are a lot of different ways lenses are designed.
Some zoom lenses change length when zoomed.
Some of those zoom with a push/pull motion. (EF 100-400mm f/4-5.6 L IS)
Others zoom by twisting a zoom ring. They might (EF 70-300mm f/4-5.6 IS) or might not (EF-S 55-250mm f/4-5.6 IS II) rotate the front element as they zoom.
Other zoom lenses zoom using a zoom ring that moves internal elements and the overall physical length of the lens doesn't change when the lens is zoomed. (EF 16-35mm f/2.8 L II, EF 17-40mm f/4 L, the EF 70-200mm series with various maximum apertures in both non-IS and IS versions)
There are zoom lenses which both extend to zoom and move the front element in and out to focus.
Some of those rotate the front element when focusing (EF 75-300mm f/4-5.6, EF-S 18-55mm f/3.5-5.6 IS II).
There are zoom lenses which extend to zoom but have internal focus.
They usually don't rotate the front of the lens when zooming. (EF 24-105mm f/4 L IS, EF-S 17-55mm f/2.8 IS, EF-S 18-135mm f/3.5-5.6 IS, etc.)
There is also at least one lens with internal zoom but with front elements that move in and out with focus. But the front element is recessed in the lens barrel enough that the overall length of the lens is not affected by the movement of the front lens during focus adjustments. (EF 17-40mm f/4 L)
There are other zoom lenses with both internal zoom and internal focus.
The only external movements with such lenses is when the zoom or focus rings are turned by the user. (The Canon EF 70-200mm f/2.8 and f/4 series, EF 200-400mm f/4 IS Extender 1.4X)
Some lenses, including some prime lenses (lenses that don't zoom), move the front elements to focus and the physical length of the lens changes.
Some of those, such as most macro lenses, will change length significantly. (MP-E 65mm 1-5X Macro).
For other lenses the length only changes slightly with focus adjustments. (EF 50mm f/1.4)
Other lenses, including both zooms and primes, have internal focus and the overall length of the lens does not change at all with focus adjustments. (EF 70-300mm f/4-5.6 L IS, EF 28mm f/1.8, the vast majority of Canon's prime and zoom lenses other than the cheapest entry level lenses)
There are prime lenses that have internal focus and don't change length when focusing. (EF 100mm f/2, most Canon prime lenses other than the cheapest few)
There are prime lenses that do change length when focusing.
Some don't rotate the front element. (EF 50mm f/1.4)
Others may also rotate the front element. (EF 50mm f/1.8 II)
It just all depends on how each lens is designed. Some designs are cheaper to make, others are more expensive to make.
Michael Clark
here. \$\endgroup\$