Air flow. This air flow can come from many different sources. The gap between the floor and maybe the wall. It depends on how your house is built or renovated.
Sealing these gaps will stop this. Use sealer around the baseboards and tape on the floor making sure that the tape is of the type that will stop air. Gaffer tape works great.
It's now possible to get big rolls of card that is used under carpets for this problem. Lay this down tape joints and run tape around the baseboard. Job done.
When it comes to removing the black mark you now have on your carpet. That's going to be a professional cleaner's job? Why. Because and this is really great detergents have different electrical charges in them some negative and some not. It's the ones with out any charge that you need for this.
If you want to do it yourself find a product that used for removing the black soot after a fire this will absorbs the charge that's keeping the dirt bonded to the carpet fiber and make it easier to remove with normal cleaning.
Lift carpet Run gapfill along bottom of skirting if these marks are where the fitter laying the carpet has punctured the underlay use flexible tape and seal these up. Refit carpet.
Get some cedar paper from B&Q. fill skirting gaps with flexible sealer, lay cedar paper. Then carpet underlay, tape all joins in the carpet underlay. Refit carpet. You must make sure you seal it air tight as the air will find its way through. That should fix the problem now you just need a carpet cleaner like me to fix the dirt problem for you.