$B$2:$B$17&$G$2:$G$17 concatenates each entry in column B (Home teams) with column G (running count of matches played). So the first item in the array would be Panahaiki1, the second Aigaleo1 and so on.
SUBSTITUTE(J$1,"MATCH_","") changes MATCH_1 to 1. This is concatenated with the contents of cell I2 to produce (also) Panahaiki1.
So ($B$2:$B$17&$G$2:$G$17=$I2&SUBSTITUTE(J$1,"MATCH_","")) compares each item in the array $B$2:$B$17&$G$2:$G$17 with Panahaiki1 and returns True if found, False if not. These Boolean values (True = 1, False = 0) are multiplied by each item in the array $F$2:$F$17 (the ID) to return an array containing the number or zero. The resulting array is added up, returning the matching ID because all the other values are zero.
Hope that helps.