Assuming each smaller square is the "managed" control, it's not clear to me why you'd expect the grid dimensions you show in some cases. For example, in the case of the 2 columns, why only 2 columns with so much space left over on the left/right? And with the denser, yellow grid - why so many rows with so much space left above/below?
Or, maybe you expect to specify the grid dimensions and then have the contents "fit" to the available space.
I don't necessarily have an answer, but you might want to clarify exactly what your expectations are.