I played with an existing answer and found a much compact alternative using SUMPRODUCT.
Formula
=SUMPRODUCT((A$2:A$4)*(B$2:D$4=A7))/COUNTIF(B$2:D$4, A7)
Output
References: SUMPRODUCT