How to understand the discrete and continuous convolution in matlab?
As Hilmar said you need to be careful of the difference between circular convolution and linear convolution. Linear convolution in the time domain translates to multiplying discrete time fourier transforms (DTFT) or continuous time fourier transforms (CTFT) in frequency and I'm sure you've seen this done. 

But as you know, the DTFT and CTFT are infinite sums/integrals so cannot actually be computed by a computer. The discrete fourier transform (DFT) can be computed by MATLAB though and it uses an efficient algorithm called the fast fourier transform (FFT) which runs on the order of NlogN time, where N is the length of the signal. You can look up that multiplying two DFTs is equivalent to performing circular convolution which just "wraps" the signal around (read Oppenheim's DSP book or wikipedia). 

Check this out which shows the difference between performing linear convolution, how to use the fft() function in MATLAB to get the result, and how circular convolution is different.

clear,close all;

a = [zeros(40,1); ones(20,1); zeros(41,1)];
b = [zeros(50,1); ones(30,1); zeros(21,1)]/2;
c = conv(a,b);
nfft = length(a)+length(b)-1;
A = fft(a,nfft);
B = fft(b,nfft);
C = A.*B;
d = ifft(C);
e = ifft(fft(a).*fft(b));

figure
subplot(6,1,1)
plot(a)
title('a[n]')
subplot(6,1,2)
plot(b)
title('b[n]')
subplot(6,1,3)
plot(c)
title('Convolution in time domain')
subplot(6,1,4)
plot(d)
title('Convolution by multiplying in freq. domain')
subplot(6,1,5)
plot(e)
title('Circular convolution by multiplying in freq. domain')