So Platinum Simmers created a very helpful guide for dealing with Zombies. Especially since I know most of you with the game have a glitched moon.
Fences around your plants protects them from zombies, however you do need to be able to access your own plants with a gate. But these sneaky zombies just go through the gate then. A very important thing you should not forget is to lock your gate! Click on the gate, then use lock > Everyone but Myself or Everyone but My Household, this keeps the zombies away from the plants from the start, but if the zombies are already attacking your plants you cannot stop them this way.