C1 input
=IF(COUNTIF(A$1:A1,A1)=1,AVERAGE(IF(A$1:A$100=A1,B$1:B$100)) ,"")
Array formula, do not press Enter after inputting, press Ctrl+Shift+Enter to end the calculation, and then fill down.