There are additives called "thickeners" available from several manufacturers (Cognis, BYK Chemie, et al). Gelatin is a common example. There are also clays which function as thickeners. You can Google thickeners and get some specific examples. They all work by increasing the hydrogen-bonding between water and other formulation components.
Components of formulated products like shampoos are either soluble (which cannot separate) or emulsions. Emulsions are very small droplets of liquids which are stabilized with surfactants (like soaps) and suspended in another liquid like water. The surfactants keep the droplets very small and prevent the droplets from coming together (coalescence). If the droplets come together they will eventually form large droplets which will separate. Selection of the best surfactant and the correct amount of surfactant are critical. Check out Wikipedia on surfactants to learn more.