If you look at the figures[7][4] array, you can see that the "S" piece (actually Z), for example, has the second index being 5.
But what point does 5 actually correspond to?
That's where your second code snippet comes into play. It takes a random tetris piece, let's say it picks the "S" piece (index 2). When i = 1, it does
i.e. it's the point (x=1, y=2) [second column, third row]
So in summary of the second code snippet: It's translating the indices in figures array into actual x, y coordinates for each square of the given tetris piece.