loopindex gets the value of a currently running loop. For loopindex("X") it's getting the index of the loop named "X".
tiletopositionX() converts a tile X index to a X co-coordinate. So the position of the tile using layout coordinates.
For tiletopositionX(loopindex) it is doing exactly that but the x index you are converting is based on the index of the loop. This is very helpful if you want to run through all the tiles.
In this example I've created 2 loops.
The first one is named "X" and runs from 0 to the tilemap display width. Which is how many tiles it can display across its width.
The second one is named "Y" and runs from 0 to the tilemap display height. Which is how many tiles it can display across its height.
Here I'm setting the tile at the position in the loop. So loopindex("X") is for the X index and loopindex("Y") is the Y index. Since the loop will run through every single tile on the tilemap this will set them all to whatever tile I choose.
Going through all the tiles like this is great for flood fill because you can check every tile and the tiles around that tile to see where the walls are.