For reasons Lefty points out, you can't easily stop this from happening. The movement is caused by the carpet being made of fibers that stand up, but bend when pressure is applied. In doing so, the item you placed on the carpet will always seek to move in the same direction as the carpet fibers bend then you stand on them
Answers that encourage you to use something that sticks the rug to the carpet or increases the grip it has are unlikely to completely solve the problem, because the fibers will simply move the sticky backing along with the carpet. Adding things to the rug is a bit like suggesting to stop people crowdsurfing at a concert by dressing everyone in a rubber suit
Your only hope is to fasten the rug through the carpet, to the floor beneath, or do something that means the carpet fibers don't get squashed/bent over as you walk on them (such as fix a board over the carpet or cut a square of carpet out and put the rug on the floor underneath.