There is no simple relationship between the physical length of the lens
and its focal length. For example, a retrofocus wide angle is generally
longer than its focal length, while a telephoto lens is shorter than
its focal length. Inside a zoom, you have several lens groups that move
independently. The focal length of the zoom depends on the relative
positions of the groups, and is not always simply related to the
physical length of the lens. That being said, the simplest possible
explanation for this behavior is that your zoom may be of a simple
retrofocus design.
Retrofocus zoom
A retrofocus
zoom is made of only two groups. The front group, of negative refractive
power and (negative) focal distance f1, makes a virtual
intermediate image of the object somewhere in front of the lens. This
group works much like the glasses short-sighted people wear: it brings
the object “closer to the eye”. The focal length of this group is close
to -35 mm.
The rear group, of positive refractive power, makes on the sensor an
inverted real image of this intermediate virtual image. The intermediate
image is the “object” for this group. The final image is like an
inverted copy of the virtual image, scaled by a magnification factor
m2 close to -1, which is negative because the final image
is inverted.
Assuming the object is at infinity, the whole lens has a focal length
f = f1×m2. This is a product of two negative
numbers, and the result is positive.

In the above simplified drawing, the first group is the lens L1, the
second group is the lens L2, the zoom is focused at infinity, the
intermediate image is at the left, at a distance x from L2, and the
sensor is at P. The magnification of L2 is m2=-x’/x.
With this design, it is easy to zoom the lens by moving the second
group. When this group is closer to the sensor, it provides a small
magnification (say around -0.5) and thus a shorter focal length for the
whole lens. When it is moved forward, closer to the intermediate image,
you have higher magnification (say around -1.6) and thus a longer focal
length for the whole lens.
However, as you change the magnification of this group, the distance
between the object (in this case the intermediate image) and the final
image changes. This distance is at a minimum when the group is just in
between its object and its image, which happens when the magnification
is -1. You can check this easily by using a magnifying glass to focus
the image of a lightbulb on a piece of paper: the distance between the
the bulb and the focused image is minimal when the image has the same
size as the object. In the case of the zoom lens, since the final image
has to fall at a fixed position (on the sensor), the intermediate image
has to be moved by moving the front group. This explains the observed
behavior of the front group: as you zoom the lens from 18 mm to ~35 mm,
the magnification m2 goes from ~-0.5 to -1 and the front
group moves closer to the sensor. As you zoom from there to 55 mm,
m2 goes from -1 to ~-1.6 and the front group moves away
from the sensor.
Example 1
This is just a theoretical (over)simplified model for a zoom where each
group is just a thin lens. The focal lengths of the groups are -35 mm
(front group) and +35 mm (rear group). Assuming an object at infinity, I
calculated the configurations of the zoom for three focal lengths. The
table below shows the positions of the lens elements (in mm from the
sensor) as a function of the focal length the zoom is set to:
┌───────────┬─────────┬─────────┐
│ f. length │ group 1 │ group 2 │
├───────────┼─────────┼─────────┤
│ 18 mm │ 121.1 │ 53 │
│ 35 mm │ 105 │ 70 │
│ 55 mm │ 112.3 │ 90 │
└───────────┴─────────┴─────────┘
And here is a drawing, to scale:

The sensor is at the right. The intermediate image (not drawn) is 35 mm
to the left of the front element. The interesting thing is that the
movements of the groups (both front and rear) match what I've seen on
most small mid-range zooms. A real zoom may have more groups (IS has
been mentioned), but only two are really needed for the zoom action.
Example 2
For a more realistic example, see this
patent for some Nikon 1 zooms.
It's not the best example because these lenses are intended for a
mirrorless camera. However, one of the embodiments is a 10-30 mm
midrange zoom (27-81 equiv.), quite close in range to a 18-55 for 1.6×.
I like this example though because of the figures.
Please take a look at the figure on page 1, and more specifically at the
arrows at the bottom, below the labels “G1” and “G2”. These arrows show
the way the groups move when the lens is zoomed from wide (W) to tele
(T). You can see that the front group moves back and then forward, while
the second group moves monotonously forward. That's what I have seen on
many wide and midrange zooms, although not on all of them (not on the
Nikkor 18-70 for example). You may notice that the second group has some
subgroups among it, including one group for focusing (Gf) and one group
for image stabilization (Gs). These subgroups are however irrelevant
when one considers only the zooming action.
Anyway, the interesting thing here is that, although some of the provided
examples have three lens groups, most (including the “preferred
embodiment”) only have two. Quoting the patent (paragraph 077 on page 67):
An optical system according to the present embodiment includes, in
order from an object side, a first lens group having negative
refractive power, and a second lens group having positive refractive
power.
This is exactly the description of a retrofocus lens.
Example 3
Here is
another patent from Nikon
which may be more relevant since it mostly describes the 18-55 kind of
APS-C zooms.
Examples 1 and 2 of this patent are for such a simple retrofocus design,
with a front group of focal length -31.51 mm and a rear group of focal
length +37.95 mm. From the data tables we see that, as you zoom the
lens from 18 to 55 mm, the front group moves first back (towards the
sensor) and then forward (away from the sensor) while the rear group
moves monotonously forward.
This patent shows also that the simple two-group design I am describing
here is not the only possible option. Consider the example 5 of this
patent. This lens has four groups that move all in different ways as the
lens is zoomed. When zooming from 18 to 55 mm, the front group moves
back, then forward, and the rear group moves monotonously forward. Thus,
as seen from the outside, it looks like the simple two-group design of
example 1, although internally it is quite more complex.
On the other hand, this particular design is actually not that far
from the simple retrofocus design. If we say that groups 2, 3 and 4
constitute a sort of “super-group”, then the lens can be described as a
group (G1) of negative refractive power followed by the super-group
(G234) of positive refractive power. Still kind of a retrofocus. This
description is not completely unreasonable as groups 2, 3 and 4 move
more or less in the same fashion: they all move monotonously forward as
the lens is zoomed from wide to tele, and their average movement is
greater than the relative movements between them. From the table of lens
data I calculated the focal length of this super-group and found that it
does not change a lot: only from 38.6 mm at the wide end of the zoom to
34.8 mm at the tele end.
Although I have only investigated a few patents, my conclusion is that
some sort of retrofocus design (but not necessarily with only two
groups) is likely on a zoom if the following three conditions are met:
- the lens is longer than its focal length at all settings
- when zoomed from wide to tele, the front element moves first back
(closer to the sensor), and then forward
- when zoomed from wide to tele, the rear element moves always forward.
The first condition is likely to be always met by SLR zooms having a
maximum focal length of no more than 55 mm.
PS: This answer has been heavily edited in order to better merge
several edits. In the process I incorporated an important point raised
by Stan Rogers, namely that the simple design is not the only possible
design.