When there is match, the formula stores the (relative to start of the range) ) row numbers (ROW($A$4:$A$19)-ROW($A$4)+1) in an array: so we might get 1,3,4,7 as matches. The SMALL function, using the ROWS($A$4:A4) part as the index to the position in the array, selects the first number (1) , then the second( 3) etc.

As the formula is dragged down ROWS($A$4:A4) is increments by 1 (1,2,3 ...) so we get the smallest, then 2nd smallest.

The IERROR is there so that when we have "emptied" the array of row numbers we get a blank rather than an error code.

Click on the formula then click on SMALL then function (fx) and you will see the row numbers displayed: no matches are shown as "",

Hope this helps