I was confused with the same problem.
but according to @hstall2529 's answer, which makes sense.
Explain it in a more straightforward way would be like:
Step 1: looking for all the numbers of nums1 in nums2.
for example, nums1=[4,1,2] in nums2 would be nums2 [1,3,4,2].
Step 2: get rid of nums1, find the NEXT GREATER NUMBER ONLY in nums2 [1,3,4,2].
Step 3: And you can see in [1,3,4,2]
The next great number of  is 3
The next great number of  is null, so -1
The next great number of  is null since  is the last element, no numbers follow it! So the result is -1
Step 4: Back to nums1's sequence, [ 4,1,2] would return [-1, 3, -1]
Hope this helps!
@BrotherDonkey it blew my mind when I found out we can iterate like this! Reading code and asking questions like what you're doing is a great way to learn:) And Yes you're correct. In this case, we update the index and then evaluate the expression.