The best way to avoid a problem is to prevent it in the first place, so one way to keep your mattress from sliding is to purchase a one-sided model. These are not meant to be flipped like older double-sided mattresses and they are usually manufactured using a non-skid material on the bottom of the mattress. This ensures it stays where you put it.
If you are not in the market for a new mattress, the most economical way to stop all that slipping and sliding around is to purchase a piece of rubber matting such as is used to keep carpets in place or to line cupboard shelves. Measure your mattress beforehand by using a tape measure to measure down one side and across either the top or bottom of the mattress. Purchase a piece slightly larger than the surface area of your mattress. It can then be trimmed to size when you get it home.
The next best solution is to purchase a piece of thin foam rubber. Again, take your mattress's measurements with you for reference. Having any part of the slippery mattress touching the box spring can void the effects of the rubber material, or at best, decrease its benefit. Place the foam rubber between the mattress and the box spring to provide traction for the mattress and stop the sliding around.
Another method of arresting mattress movement is to purchase stick-on hook-and-loop strips. These have an adhesive on one side. Peel away the protective paper and place the strips with the hook pieces on either the bottom of the mattress or the top of the boxspring, placing the loop pieces on the opposite side. Be sure the pieces will match up when you place the mattress back onto the box spring. The strips attach to one another and stop the mattress from sliding.