I am a moisture nut. I have to have it in all recipes. I don't mean extreme moisture, but balanced in the recipe. And some are actually extreme.
Definitely the recipe. You can overbake a great moist recipe and it will still be moist. Last week I was making some cupcakes. I always pull out the top shelf before the middle and I forgot. I was making more than I needed as usual. My daughter loves to take them to school. So I packaged the others for the client and had to taste the top shelf ones to make sure I could send them to school. The top was definitely crunchier, actually in a good way, but the cupcake itself was perfect.
I don't advocate syrups unless they were planned. In those cases, the cake is dryer and sturdier in order to accept the syrup that makes it balanced.
I like recipes that use buttermilk, sour cream, and half and half. Some have oil. I used to shy away from butter cakes because I felt their shelf life of staying moist was shorter, but through recipe manipulation, the recipe I wrote about above was a butter cake. It did have half and half which I make myself. That may be why my moisture quotient went up in that recipe.
I like whole eggs, even if they are separated. My cakes that use whites only tend to be ones that use an infused flavor sugar syrup or a brushed on liqueur. Yolks add a richness and moisture.
I have found recipes with milk to be a little drier.
Then there is method. Over-mixing will cause batters to be tough, seeming to be less moist.
There is also the use of lots of vanilla bean paste. Even though this is a tiny thing, all of the ingredients work together to help with moisture.
Light pans will help with moisture retention. Dark pans bake hotter and rob some moisture. Quality pans have a very noticeable effect. I did an experiment with Williams-Sonoma regular, their Goldtouch, and another good brand. The Goldtouch was so much better. Now I use only Goldtouch in every size pan they make and use Magic Line for the rest.
Accurate temp is a must. Get an independent thermometer. Watch for hot spots in your oven. And even if you have a convection, the top of the oven is hotter and the front (or wherever the exhaust for the fan is located) is cooler. Move your thermometer around and you will see. So keep your thermometer on the middle shelf away from the exhaust.