Hi,
The solution provided by HansV MVP requires You to have an Office 365 subscription OR MS Excel 2021 version.
In case You do not have the above MS Excel versions, please consider following suggestion:
Step 1) Table name is SourceData.
- I created a helper column - column C in screenshot below.
-- In cell C2, please write the following formula: **** =IF(COUNTIF($A$2:A2,[@Key])=MAX(COUNTIF([Key],[@Key])),"",", ")
- Please drag the formula down to more rows.

- This helper column can be anywhere else OR can even be hidden after Step 1.
Step 2) In cell E2, please write the following formula:
=IFERROR(INDEX(SourceData[Key],MATCH(0,INDEX(COUNTIF($E$1:E1,SourceData[Key]),0,0),0)),"")
- Please drag the formula down to more rows.

Step 3) In cell F2, please write the following formula:
=IFERROR(TRIM(CONCAT(INDEX(INDIRECT("B"&MATCH(E2,SourceData[Key],0)+1&":C"&MATCH(E2,SourceData[Key],0)+1+COUNTIF(SourceData[Key],E2)-1),,))),"")
- Please drag the formula down to more rows.

Please respond if You require further assistance. I will try My best to be of help.
If I was able to help You, please mark My response as answer and helpful.
Thank You!