Why is the magnetic field inside a solenoid constant?

First, remember that the magnetic field is only uniform for a long solenoid, and even then only if you restrict your attention to regions far away from the ends.

The fundamental reason the field doesn't depend on position along the length of the solenoid is that, when you're far from the ends, the magnetic field of a long solenoid looks almost the same as that of an infinite solenoid. The field is "mostly" caused by the current relatively near you, so it doesn't matter much if the solenoid extends forever or just for a very long way. For an infinite solenoid, the field has to be uniform as a function of position along the axis, since every point along the length is the same as every other point (if you prefer, the system is translation-invariant along the axis).

I think the more surprising thing about the magnetic field inside a solenoid is not that it's uniform along the length, but that it's uniform in the perpendicular directions -- that is, that the field doesn't depend on whether you're close to the axis or far from it (as long as you're inside it). It'd be easy to imagine the field would either drop off or get stronger as you move perpendicular to the axis, but it doesn't (again, for a long solenoid when you're not near the ends).

The deep principle here is Ampere's Law. If you draw any closed loop in space, and "add up" (integrate) the tangential ("forward-pointing") component of the magnetic field around the loop, the total equals a constant times the amount of current passing through the interior of the loop. Now choose your loop to be a rectangle like, for instance, the red rectangle in the image in this website. If you move the upper side of this rectangle up and down (keeping it inside the solenoid), the enclosed current doesn't change, which means the magnetic field strength can't change.