Quasi-optimal polynomial approximations for parameterized PDEs with deterministic and stochastic coefficients