Explanations for why forces like gravity obey an inverse square law usually refer to flux lines which decrease in density $\propto \frac{1}{4 \pi r^2}$.
However there are many other cases of quantities which decay due to the geometry, such as the potential 2D flow of a fluid from a line source which is $\vec{v} = \frac{\Gamma}{2 \pi r} \vec{\hat \theta}$ which also decays due to the geometry of the dimensions (but in this case the velocity is azimuthal so one can't really use an argument related to flux lines decreasing in density).
My question is, more rigorously, what conditions need to be satisfied in order for a law like this to be produced? My intuition is that the potential flow decay relies on $\vec{\nabla} \cdot \vec{v} = 0$, and probably the same with the flux lines divergence, is this the only necessary assumption?