Answer: Cats can sometimes be deterred using the repellent sprays labeled specifically for cats. Other deterrents include using a motion activated water hose for example, or covering the soil with "uncomfortable" items such as thorny branch clippings, tin foil, or pine cones. Sometimes using a different mulch material will also help, especially if you wet it down right after you spread it so that it compacts somewhat. Or, you might be able to distract them by providing a more attractive litter box area such as a sand pile. Finally, once the plants grow enough to cover the ground they usually lose interest.
Raccoons can be quite destructive in the garden. In my experience the best deterrent is a strand of electric fence. Another approach is to fence the garden with wire mesh such as chicken wire and leave the top foot or so floppy or loose and leaning outward. This makes it more difficult for them to climb it. (This might also work for the cats.)
Here is some additional information about the raccoons you may find helpful. (It also illustrates the type of electric fence set-up.)
Good luck with your gardens!
Q&A Library Searching Tips