What Causes Spotting

S
Foe the last few cycles, I have been spotting 2-4 day before af is due. Is there something I should do to not spot? What could the spotting mean?