Whether a zoom lens is constant aperture or variable aperture has first to do with the design, a secondly to do with mechanical factors like opening or closing a diaphragm.
A zoom lens works by having some elements move to change the focal length. This works because of the equation for the focal length of a thick lens:
(1) Phi = phi_1 + phi_2 - (t/n)*phi_1*phi_2
(2) EFL = 1/Phi
Where Phi is the total optical power of the thick lens, phi_1 and phi_2 are the optical power of the first and second surface, t is the thickness between them, and n is the refractive index of the lens. EFL stands for effective focal length and is what is colloquially referred to by saying focal length.
Any optical system containing any number of elements can be modeled accurately as a single thin lens. This equation also works for thin lenses, but the t/n term disappears, as t=0. A 50mm f/1.8 lens can be modeled as a single thin lens of focal length 50mm, as can an 18-300mm lens set to 50mm.
You can also use this formula to model 2 thin lenses. As long as the lenses are positive, you can see that by pushing them further apart the t/n term will get larger. As it grows, the power decreases and the focal length gets larger.
This is the essence of a zoom lens.
As soon as you introduce an aperture stop into an optical system, you have what are known as entrance and exit pupils. The entrance pupil is the image of the aperture stop formed by the elements in front of it, and the exit pupil is the image of the aperture stop formed by the elements behind it.
The pupils have a position and size just like a lens element or the actual aperture stop itself. The f/# of a lens can be approximated by
(3) f/# = EFL/EPD
Where f/# is the 'focal ratio', EFL is the effective focal length, and EPD is the entrance pupil diameter.
Let's stick an aperture stop in the middle of two thin lenses separated by air. If we increase the EFL of the lens system by moving the lens in front forward, the EPD will change with it. If we increase the EFL of the lens by moving the lens in the back backwards, the EPD will not change with it, since that lens does not affect the entrance pupil in any way.
It happens to be the case that unless you make an extremely large zoom range, the magnification of the aperture stop responsible for the EPD increases at the same rate as the focal length. Since both the numerator and denominator of (3) changed by the same relative amount, the ratio is still the same and thus our lens may have moved from 70mm to 200mm and maintained an aperture of f/4.
If we moved the lens in the back, the lens would have slowed down to about f/10 or so by zooming from 70mm to 200mm.
A modern zoom lens has 3 or 4 zoom groups, so it is more complicated than this simple explanation. If all of them are in front of the aperture stop, this is still true. If most of them are in front of the aperture stop, the manufacture will tend to program the diaphragm to open/close while the lens zooms and just cheat the gap to make it behave like a constant aperture lens.
You may wonder why not just put all of the groups in front of the stop and be done with it - there are two key motivations:
1) If you force all of the zooming to happen in front of the aperture stop, the lens is necessarily longer than if it could zoom on both sides.
2) It is easier to design a well-corrected lens if you are allowed to alter the position of the elements on both sides.