Fencing
A goat alone will be difficult to keep behind a fence. If a goat is in a herd, then the likelihood that they escape becomes less. As goats ages, they are less agile than when they are young.
Does
For our does, we uses 4 feet fencing. Note, for larger breed this might not be tall enough. If there are trees close to the fence, the goats will use the fence to eat of the leaves. If the fence is not tight enough, than it will lower down giving the other goats the opportunity to jump the fence. If you have a fence with wooden post and a plank across, this should not be a problem. The metal fence post does have the problem that they are more flexible. Frequent climing causes the fence to slide down. We uses 2 metal post and then a wooden post which keeps the fence up.
Bucks
Buck are a different story. In the fall during rut season, bucks have a mission to get over that fence. A young buck is difficult to keep behind a four feet fence. The dwarf breed don't jump over the fence but rather climes the fence. Watch the video to see our Valentine climes over a four feet fence.
The fence contained all wooden post. The solution was adding a top fence board which was angled at 45 degrees. prevents the bucks to jump over the fence. Certain bucks has no tendency to jump the fence, while others are enthusiastic to get over it to get to the girls.
If you think that water will stop them, you are sadly mistaken. We have a pond that separate the does from the buck. One of our bucks simply swam across the pond to be with the does in heat. So we ended up fencing along the pond side as well.