Asymptotically compatible discretization of parametrized variational problems with applications