You must respect the following order.
Unit for results is in millimeters.
Choose the right frame size and the right crank arms length. The frame size is given center to top in mm. In the case of MTB, frame size is also given by range (S | Small, M | Medium, L | Large or XL | Xtra Large). The top tube length is given center to center in mm.
Adjust the saddle (height and setback). The saddle is adjusted to produce maximum power at a minimal aerobic cost.
Choose and adjust the stem.