Looking quickly at your loop structure, it seems that if you want a row for every iteration you must count how many times you have reached the assignment statement. So you could define a counter before entering the outer loop call it iCount, and then increment it each time you reach the assignment statement and use that for indexing into the table you are creating. So something like
% initialize counter
iCount = 1;
for j=1:1:M
reference1=model{j,1};
A = raw(strcmp(raw_model,reference1),2);
for i=1:1:P
reference2=problem{i,1};
B = A(strcmp(A{:,1},reference2),1);
quantity=height(B);
C = [reference1,reference2,quantity]
T(iCount,:)=table(C)
% increment counter
iCount = iCount + 1;
end
end