How is the maximum number of Men-at-arms and knights determined?
They are determined by your tier and various modifiers. The number of Men-at-Arms slots and the number of Knights are calculated separately, although they have some of the same inputs, so that a bigger realm will generally have more of both.