Time dilation and length contraction are connected geometrically, through a construct called minkowski space. Roughly speaking, you define this space by: ds^2 = -c^2dt^2 + dx^2 + dy^2 + dz^2. Lorentz transformations are just symmetries in this mathematical picture (SO(1,3) symmetries, basically just rotations with some funky properties because minkowski space isn't exactly R^4*). Because they are symmetries of this space, then the length of any path computed in this space should be the same in two different reference frames.
This is often written like this:
I = -(cΔt)^2 + (Δx)^2
where I is invariant under Lorentz transformations. This might be a bit confusing, so I'll re-explain this from an angle you are likely to understand:
In R^3, you can compute the distance between two points using: ds^2 = dx^2 + dy^2 + dz^2. This has a symmetry SO(3), or rotations in 3 dimensions. The distance:
I = (Δx)^2 + (Δy)^2 + (Δz)^2
Remains unchanged when you rotate it.
Physically, I (in special relativity) could be a combined measurement of the length of an object, and the time between two events. If you "rotate" this, or apply a Lorentz transformation to it, Δt and Δx will change. But since I is invariant under this, they must transform in a related way so that their sum stays the same.
* Technically, I should say "minkowski space isn't exactly R^4 with the usual metric"