To add to Stephie's answer, sometimes dairy is incorporated for a variety of reasons. In some cases, like a coffee cake, sour cream or yogurt can account for a good amount of the moisture and fat in the batter. Rich dairy products like cream and sour cream usually lead to very tender baked goods, due to helping to incorporate more fat (the fact that it's already emulsified helps too).
Soured dairy, like yogurt, sour cream, and buttermilk are frequently used so that their acidity will react with baking soda in the recipe for leavening.
Finally, yogurt and buttermilk often have stabilizers like guar gum, xanthan gum, and carrageenan. These will retain moisture after baking to help the finished product be more moist.
Whether a substitution will work would depend on which functions the dairy ingredient is filling, and which characteristics the substitute matches.