Why try to maximize number of grounding vias in RF PCBs?
You're actually talking about two very different things.  One, via stitching, is the grid-like pattern of vias you might see connecting two ground planes.  

The other, via fences, are vias that completely surround an RF trace on all sides, save maybe for the end terminating to an antenna or similar.  

Now, it is a good idea to stitch ground planes together with some sort of regular pattern (within reason, you can really kind of do this to your taste) on any PCB, whether it is carrying DC or 5GHz signals.  It well ensure that any copper islands that might have gone unnoticed are actually connected to ground (it happens to the best of us), ensures everything has the shortest possible path to ground, and it generally keeps ground as ground.  

Now, ground isn't a particularly useful concept at high frequencies.  And even at DC, there are ground return currents flowing through your ground planes, and the copper does have a tiny bit of resistance.  Ground is just a fantasy, there is no magical slab of copper that is at the same potential at every point.  Ground just means something we try to keep at close to the same potential, with varying degrees of success, and chose this potential as the 0V reference for the rest of our circuit.  

As soon as any current starts to flow however, it will cause a voltage across the copper through which it is flowing, serving to both spread the current out but can also cause our ground to 'bounce' around depending on which part of the PCB you are looking at, and, well... nothing is ever REALLY at the same potential.  Even ground.  Via stitching is considered a 'best practice' and low-effort way of ensuring your ground is more tightly coupled in terms of the voltage potential across one part of ground to another, etc. etc.  

Like they say, you can never have too many ground pins.  It works for ground vias as well.   

Another important use of vias is thermal performance.  Vias serve as fairly good conductors of heat, certainly much better than FR4.  Whenever vias are being used for thermal performance, you will generally see them packed as tightly as is reasonable, covering a swath of copper which is expected to get toasty when the board is powered up.  And even in more modest needs, it is almost always preferable to have a PCB that is more tightly thermally coupled than less.  If the temperature is more similar across the PCB, then all the stuff that drifts with temperature (which is pretty much everything on the board) will drift together.  

Now, for RF boards, things are a little different.  For one, return currents don't really give a crap about your ground plane anymore.  At low frequencies, our ground return currents were somewhat diffuse, and took the shortest geometric path to the lowest point of potential (the thing that grounds our ground plane, like to the ground of the power supply, a battery, whatever).  

At even modest frequencies, the ground return currents are dominated by the reactive component of impedance.  Reactance (the imaginary component) of complex impedance is a measure of impedance that is due to various elements in a circuit storing energy at a given rate, as opposed to the resistive (real) component, which is simply impedance caused by energy being dissipated at a certain rate.  

Reactance is frequency dependent because the stored energy isn't just gone, it will return to the circuit, and how fast things are wiggling are going to determine how much time (and thus, how much energy) is going to get stored before it gets released back with the next wiggle.  

Reactance is always due two either energy stored in an electric field, or in a magnetic field.  And capacitance and inductance are simply a measure of the capacity of something to store energy in an electric or magnetic field, respectively.  Everything is starting to come together now, wouldn't you say?

Current is going to follow the path of least impedance.  As the frequency goes up, our return currents increasingly need to minimize the inductance and capacitance formed between the positive current and ground return current.  It wants to minimize how much energy is able to be stored in parasitics.  

Our ground current is going to do everything it can to flow DIRECTLY under the path of the original current.



As you can see, 100MHz is unimpressed with our nice, short ground paths we made available to it.  In fact, it ignores them entirely.  

Which is why the via stitching and fencing on RF boards is done for completely different reasons than anything to do with ground or keeping a good ground potential.  Yes, I am finally going to actually answer your question! 

The sub ~300GHz range of electromagnetic waves we generally call radio waves are the result of charge carriers being accelerated.  Any time you accelerate any charge carrier, an electromagnetic wave is emitted, which due to some Serious Physics that is beyond the scope here, contains a little bit of energy, momentum, and angular momentum, and is radiated just right to conserve them.  Of course, it can interact with distant charge carriers, and that momentum, angular momentum, and energy can be imparted back into other charge carriers, causing them to be accelerated.  This is, of course, the physical basis of all radio technology.  

For charge carriers to be accelerated, the must be mobile.  In other words, we need conductors.  

The terrible truth here is that literally everything conductive is an antenna, and will happily radiate and pick up pretty much everything that is of a frequency high enough to make the wavelength small enough to fit in said conductor.  

Our only real defense against this is to make all our conductive paths too short to be effective radiators at the frequency of interest.  

As such, it is considered best practice to switch any copper pours on an RF board with vias spaced at a minimum of 1/10th the wavelength of the highest frequency of interest, or λ/10.  Minimum.  When possible you really want to aim for λ/20 spacing in your vias, in a grid pattern.  

Which brings us to the most horrifying part of all, and arguably the most important reason for stiching and the primary impetus behind via fences:  everything that ISN'T a conductor of charge carriers...

...is a fantastic conductor of electromagnetic waves.  

That's right, everything that we call insulators, dielectrics, including a vacuum or nice PTFE wire insulation or the FR4 laminate of our PCB - they're all what conductors are for current, but for electromagnetic waves.  They are conductors of electromagnetic waves.  Conductors, on the other hand, are insulators (reflectors is probably a better analogy) of electromagnetic waves.  

If you have cable TV or internet, you're familiar with those 75Ω RG6 or RG59 coax cables that carry it all and make it work.  Look at a cross section, you will see white material in between the shield braid and the single center conductor.  That is dielectric foam.  The signals traveling down that cable are not carried by the copper conductor, they are carried by the white foam.  Coax cables are not your regular old conductive cables.  Coax cables are wave guides.

When the frequencies get high enough that the wavelengths are of similar size to copper features on the PCB, you have to fight a constant battle to keep all these electromagnetic waves bottled up and going where you want them to go and not where you don't.  And they will happily travel through the tasty dielectric core of your PCB, made of FR4, all the way out to the side of the board, to radiate out like little wiggly bats out of hell.  

And your two ground planes will serve as excellent wave guides! They will bounce between them on their way out the side of your board, and presumably directly into the RF measuring equipment being used at the FCC certification you're about to fail.  

So we lay down a grid of vias spaced much tighter than the shortest wavelengths we need to worry about.  No less than λ/10th, but better λ/20.  Just like the grid on the door of your microwave oven, these vias are packed too tightly and these waves stop leaking out.  

Via fencing is done for much the same reason, but usually because we are actually trying to radiate some waves, but we want to keep them bottled up until they can escape through some sort of antenna feature or whatever in the way we would like.  Often, via fences are also serving double duty as the outer part of a wave guide, like a planar coax if you will.   On top of carefully calculated microstripping dimensions of course, the clearance is important.  

Anyway, to finally answer your question: all those vias are to keep the wiggles in.