What is the magic in packaged pudding mixes?
The Industrial Product

By way of example, this is the list of ingredients from Jello Vanilla Instant Pudding and Pie Filling mix (a very common brand in the US):

Sugar
Modified Cornstarch
contains less than 2% of Natural and Artificial Flavor
Salt
Disodium Phosphate
Tetrasodium Pyrophosphate (for Thickening)
Mono- and Diglycerides (prevent Foaming)
Artificial Color
Yellow 5
Yellow 6
BHA (Preservative)


The ingredients that are not well known, or are that are relevant to the texture are:


Modified cornstarch.   The label does not specifically say how the cornstarch has been treated or modified, but it is likely that it is pre-gelatinized which is what allows it to be "instant pudding", thickening with the addition of cold liquid.
Disodium Phosphate.  Anti-caking agent.  This allows the mix to flow freely after storage.
Mono- and Diglycerides. Emulsifiers.
Tetrasodium Pyrophosphate.  Per Wikipedia:  


  Sodium pyrophosphate is used as a buffering agent, an emulsifier, a
  dispersing agent, and a thickening agent


Note that this both emulsifies which helps create smoothness and uniformity, and thickness.


What you do not see in the mix is any true dairy or egg products.  The pudding is entirely a creation of these thickening agents, and the flavor only from the natural or artificial flavors (which might or might not include vanilla extract, but more likely are vanillin and other flavors).

Home Production

Puddings (at least in US usage of the word) are a variant on custards, where the thickening power of eggs in a basic custard is supplemented with a starch.

It is not really possible to achieve a consistency identical to that provided by the industrial ingredients, so if you are using that as your standard, you will fail.

Still, an extremely smooth product with a delicate mouth feel (which in my personal opinion is actually superior) is possible by creating a pudding based on:


Rich dairy, about 10-18% or more milkfat (half and half, or richer)
Egg yolks (but not the whites), for thickening.  The natural lecithin in the yolks contributes smoothness, and the proteins contribute thickness.  Omitting the egg whites removes the somewhat rubbery mouthfeel that the albumens in the white contribute to thickened dishes.
Cornstarch for supplemental thickening and to help bind the pudding.


The ratio is very very approximately:  1 quart (1 liter) dairy to 6 eggs yolks to 4 tablespoons cornstarch.

These puddings can be created stove top or baked in the oven, and can be flavored in a variety of ways.  In either case, you must use good technique to avoid curdling the eggs.


Beat the yolks to  light golden color.
Mix the cornstarch, sugar (and other dry ingredients) with a small amount of dairy, just enough to create a smooth slurry.  Then add the remainder of the dairy and egg yolks, and mix.
Bring to a slow bubble (about 180 F, 82 C) on top of the stove.
Strain and chill.