the error occurs already in the creation of the two signals. how should the lowpass know how exactly you produce your signals and do that what you want. the creation of y2 brings just a signal which unknown way of creation (from the filter's view). Thats why
fs = 8000; % sampling frequency
f1 = 1000; % frequency 1
dt = 1/fs;
T = 0.2; % time
t=(0:1/fs:T)';
y1 = cos(2*pi*f1*t);
lowpass(y1,3000,fs);
f2 = 7000; % frequency 2
y2 = cos(2*pi*f2*t);
figure;
lowpass(y2,3000,fs);
results into the same frequency plot.