This is where the terracing comes in -- using some kind of barrier to keep the bedding in place.
It could be block, landscape timbers, rock, brick, metal skirting, random logs from trees you've cut, ...
You need to first address the drainage problem through re-grading the area, digging water diversion ditches, and/or laying French Drain.
Then you need plenty of good, absorbent bedding -- wood chips would be the most stable but I believe that a mix of different materials and textures is...