Manufacturers give colorful stripes to toothpaste by using a two-in-one like tube within a tube. The main tube is filled with white paste. Another tube within the main tube is filled with colored paste. This type of design prevents white and colored pastes from mixing. A few holes are made on the upper part of the colored paste tube so that when the tube is pressed colored paste also comes out through these holes forming colorful stripes.
Some manufacturers also use two different but non-mixing pastes in a single tube. But this method does not give accurate result.