Your first code should work so long as I is within the array confines. There's really no other way it could break.
A string array is a list of strings, so if you set A$[0], all the other items in the array are still empty strings
so A$[1] is an empty string, and A$[1][2] will be an out of range error
But if I=0 and in the position 0 of the A$ array there is a string, why the first one is not working? It's strange...
Your code works for me in both the 3DS and Switch versions. Is this really all of the code? Did you make a typo somewhere?