How does pudding make cake moister?
Instant pudding contains a significant amount of cornstarch. It also contains less significant amounts of disodium phosphate and tetrasodium phosphate. All three of these ingredients will have an effect on cake. 

Starch absorbs water and gels during baking. This interferes with gluten formation to some degree. If you break down the starch in flour, which is, in part, how you make cake flour, the starches are more able to do this job. Cornstarch is nearly all starch. Adding it to your cake will make your flour behave more like cake flour, while increasing your cake's hydration. 

The phosphates also affect your cake, but to a lesser degree. Depending on the other ingredients in your cake, they will act as a leavening agent that will help to prevent the addition of all that pudding from making your cake too heavy. 

Many bakers rely on a secret trick that you might try instead of pudding. They replace two tablespoons of flour in any cake recipe with cornstarch. I do this not only in cakes, but in pie dough.