I always thought using "X", "Y", and "Z" for the three dimensions of an array could be misleading for beginners. And this is a good example for it.
If I understand it correctly, you're having some instances of a sprite and want to store their X/Y position values into an array?
Let's assume there are 10 instances. For each instance you need to store 2 values (X and Y). That makes 20 values to be stored.
But if you use an array with width and height set to 10, there are 100 cells (10*10), so there are 80 cells in the array that you never use.
Try to think of other names for the array's dimension. For example, call the width of an array "sprite instance" and the height "position values". Now it gives you a better approach.
If you think of it like that, you would set the dimensions of the array: "sprite instance" to 10 and "position values" to 2. That creates an array with 10 * 2 = 20 cells, exactly the amount needed.
And you would access them with an index. 0 = first instance, 1 = second instance, etc.
Array.at(0,0) -> x-position of first instance
Array.at(0,1) -> y-position of first instance
Array.at(1,0) -> x-position of second instance
Array.at(1,1) -> y-position of second instance
For the index, there are several options. For example, if the instances of the sprite are once created and then never destroyed, you could simply use their .IID or you could add an instance variable that you set to a unique number per instance, beginning with 0.
I know this sounds confusing at first, but if you get used to it you will avoid further issues. (Just think of 80 sprite instances for example, that would make your array use 6400 cells with your current method, although only 160 are needed)