I had given a sine wave of frequency 2kHz as input to two microphones placed near to each other. The data grabbed by two microphones are then plotted in MATLAB and it was found out that the initial delay of samples between the two microphone was almost 2 samples. When I looked at the complete plot of both the data's in MATLAB the delay was found to be varied. What may be the reason for that.
Looks like clock drift.
That happens when you have two independent clocks in the system. Even if they are nominally the same (40 kHz). There will be slightly different and there will be relative drift between them.
Typical audio clocks tend to be within 10ppm of their nominal target. So a drift in the order of 1 sample/second is perfectly normal and expected.