On the optimal approximation of Sobolev and Besov functions using deep ReLU neural networks