This Help page ([['''Help:Substitution]]''' or [['''Help:Subst template]]''' or just [[Help:Subst]]) tries to describe how "subst" templates work. Except it does a really poor job. Go check out [[wikipedia:Help:Substitution]], since that will probably be more helpful.