Outsmarting critters that get into your garden is harder than gardening itself. That’s a fact. If critters are getting into your garden, you need to wage an all-out war against them, as once they set up housekeeping near your garden you will find the score to be consistently rodents: 10 You: 0
First of all, for squirrels you will need a non-climbable fence. This is the hard part, as it means a fence made out of a smooth, slippery material. Corrugated metal works; so do sheets of aluminum. Buying new is an expensive proposition, so check with scrap yards or with your neighborhood packrat.
The type of fence is important. Welded wire fence with 2 by 4 inch openings is not small enough to keep critters out. You will need to add either ½ inch opening chicken wire or hardware cloth to the bottom, at least two feet up the welded wire fence. Burying your fence is also important. A few inches is not enough. Bury your fence at least a foot, and bend outwards in a L shape to discourage rodents digging under the fence.