Now that you mention it, No, I have no good answer.
Unless it is because toothpaste, unlike groceries, is also sold in chemists' shops where all tubes of ointment etc. are boxed. Presumably, as it was easier originally to stamp the boxes clearly than stamping the tubes, and after all medical supplies have to be clearly marked.
I mean you will undoubtedly be unpleasantly surprised if you confuse a tube of mustard for toothpaste, but it is unlikely to kill you. But confusing an ointment that is only to be used externally with toothpaste could be exceedingly dangerous.
Foodstuffs such as tomato paste, mustard, mayonnaise and many others can be sold in tubes, but these are supplied in crates by the wholesalers who leave it to the retailers to solve the problem of how you actually stack tubes of anything neatly on a shelf.