Mean field methods for stochastic control and optimization problems