Assuming that you cannot pre-allocate your matrix, something like this could work:
all_vars = ;
for n = 1 : 50
y=load(['a',num2str(n),'_', num2str(k) '.mat']);
c = y.c;
d = y.d;
all_vars = [all_vars; [c d]];
I changed the name of your matrix, because all is a function name you could need later in your code. Naming variables the same as built-in MATLAB functions is called ‘overshadowing’. MATLAB will use the variable instead of the function afterwards, making the function useless until you change the variable name.