Finding the right size stem is important to dial in the fit of your bike. This article is going to focus on defining dimensions of a stem, and not the fit. Most of the important dimensions can be identified on a threadless stem, so let's start with those! Here's a neat infographic:
Length and angle are dimensions that affect fit, while steerer diameter, clamp diameter, and stack height are going to affect compatibility. Different combinations of length, angle, and position on the fork steerer can yield the same bar position, so do some trigonometry or trial and error to find the best fit for you!
Dimensions are mostly going to be the same for a quill stem. Height above minimum insertion is an important one specific to quill stems. That looks like this: