Here an array version that spills the entire result, assuming no Excel version constraints as per the tag listed in the question:
=LET(in,A1:F16, h,TAKE(in,1), data,DROP(in,1),ux,UNIQUE(TAKE(data,,2)),
REDUCE(h, SEQUENCE(ROWS(ux)), LAMBDA(ac,a, VSTACK(ac, HSTACK(INDEX(ux,a,),
BYCOL(FILTER(DROP(data,,2), TAKE(data,,1)=INDEX(ux,a,1)),
LAMBDA(f, IF(SUM(N(f="Y"))>0, "Y",""))))))))
Here is the output:

This is just another application of REDUCE/VSTACK pattern (1). It depends on a single data range (in, i.e. easier to maintain), and then combining TAKE and DROP functions extract the necessary information. It iterates over all row index position of ux (Unique rows from the first two columns of data). On each iteration, concatenate the given row a via HSTACK with the output of BYCOL. This function uses as input the data with year information (without the header), filtered by iteration id (INDEX(ux,a,1)), then on each columns counts the numbers of Ys, in case the counts is greater than 0, put on that column Y otherwise an empty string.
(1): Check my answer to the following question: how to transform a table in Excel from vertical to horizontal but with different length.