Gauss's law shows the relationship between the charge distribution in a closed surface and the generated electric field. Gauss's law of electrostatic field is similar to Ampere's law of magnetic field, and both of them are concentrated in Maxwell's equations. Because of the mathematical similarity, Gauss's law can also be applied to other physical quantities determined by inverse square law, such as gravity or irradiance.
Brief introduction of other situations of gauss theorem.
The flux of Gauss theorem electric field intensity to any closed surface only depends on the algebraic sum of charges in the closed surface, and has nothing to do with the position distribution of charges in the closed surface or outside the closed surface. In the case of vacuum, σ q is the algebraic sum of free charges in a closed surface. When there is a medium, σ q should be understood as the sum of closed free charge and polarized charge in a closed curved surface.