If you do not need or dislike the dynamic queries, and the number of names is known and limited, then try this query:
select *
from
(
select ID, [Name], C = concat('Name', row_number() over (partition by ID order by [Name]))
from #yourtable
) t
pivot
(
max(Name) for C in (Name1, Name2, Name3, Name4)
) p