When beating the carpet with a stick, mud flies away because of inertia. The rug is at rest, and it will stay at rest because of the inertia, which is why when a carpet is thrashed with a stick, dust comes out of it.
When the rug is at rest, and the dust also tends to stay at rest; however, when the carpet is beaten, it gains velocity, but dust remains at rest, so the dust particles fly off the carpet. When the stain is fresh, you should not mess with it right away, but wait until it has dried. Be careful while cleaning, as one false move and you could be staring at the stain on the carpet indefinitely.