It's the reverse order. First you pick how many unit squares you want to fit. Then you try to fit them in the smallest container square possible.
For example for 3 unit squares, the smallest size of the container square is 2x2. (But in a 2x2 container square you obviously can also put 4 unit squares.)