How do I pick variable length passwords uniformly at random? How do I pick passwords uniformly at random when given a min and max length?

It seems that if I first pick a random length, then choose random characters, this procedure will choose shorter length strings preferentially when you consider the number of different strings of a fixed length that are possible.
In practice, it is sufficient to pick a random password with the maximum allowed length.

Assuming that your alphabet has $n$ different usable characters, the total number of passwords of length up to $k$ is $$t(k) = n + n^2 + n^3 + \dotsb + n^k = \sum_{j=1}^k n^j = \frac{n^{k+1}-1}{n-1},$$ and thus the fraction of all passwords that have length less than $k$ is $$\frac{t(k-1)}{t(k)} = \frac{n^k-1}{n^{k+1}-1} \approx \frac 1n.$$

For example, assuming that your passwords are composed of printable ASCII characters ($n = 95$), all the passwords shorter than the maximum length make up only about $1/95 \approx 1.05\%$ of the total password space.

(In any case, if these "passwords" are meant to be memorized by a human, it's generally much more effective to use a passphrase selected by picking random common words from a suitable dictionary.  See diceware for a popular example implementation.  Depending on the size of the dictionary used, each such word can encode about 10 to 13 bits of randomness, whereas two random printable ASCII characters encode a little over 13 bits, but a single meaningful word is much easier for a human to remember than a pair of random characters.  Of course, such passphrases do end up being a couple of times longer than a random character sequence of equivalent entropy, but this is only a serious problem if you're running against some kind of a hard maximum length limit, in which case the existence of such a limit is the real problem.)