There's two ways that toothpaste is produced:
1) Striped toothpaste can be produced by including two different colored toothpastes in an unusual type of packaging. The collapsible tube has two tanks, one filled with each color paste. Squeezing the tube pushes the two pastes out the opening. The tube nozzle layers the pastes to produce a striped pattern.
2) To keep the cost of packaging to a minimum, it is now common for tubes to be filled with striped paste (e.g. Aquafresh). As the tube is squeezed, the stripes flow parallel to each other and do not mix. The patterned paste that gets dipensed is simply a narrower version of what is in the tube. Filling is done using a multi-nozzle filling head that dispenses a different colored stripe in each direction. To keep the stripes parallel to the axis of the tube, the head starts at the bottom and retracts as it fills, staying just above the level of the paste. Tubes with two compartments are generally reserved for toothpastes containing two formulas intended to react together and therefore kept isolated until dispensed (e.g. Colgate Simply White).
The stripes don't mush together to start with because all the mushing usually happens lower down the tube (where you press) and the pressure just pushes non-mushed toothpaste that is further up the tube out. The pastes are thick enough not to mix well. Also, if you press in the middle of the tube, it just pushes the toothpaste up or down away from where you pressed and pressing in another place does the same, so it's just sliding up and down the tube, rather than getting properly mixed.
However, by the time you get to the end of the tube, there is a slight mixing of the colours, just due to all the previous squeezing eventually managing to mix it a little.