Unlike electric charges magnets have two poles. Electric charges have electric field lines that start or end at the charges but magnetic field lines do not start or end at the poles, instead they form closed loops. Note that the magnetic field lines continue their path even in the interior of the magnet as shown in Figure 1.
In Gauss's law for electric fields we enclose the charge or charge distribution symmetrically (so that the integral can be evaluated easily, see in Gauss's law for electric fields) and the electric flux through the Gaussian surface due to the charge distribution was proportional to the total charge enclosed by the surface. Or mathematically for charge $q$ enclosed by a Gaussian surface, the electric flux through the surface was $\Phi = q/\epsilon_0$.
It was because there was a net flow of electric field lines through the Gaussian surface. Since magnetic field lines always form closed loops, the net flow of magnetic field lines through a closed surface is not possible. In Figure 2 below, the magnetic field lines entering the closed Gaussian surface must come out of the surface and there is no net magnetic field lines through the surface. Therefore the magnetic flux through the surface is zero.
No magnetic monopole has ever been found and perhaps they do not exist but the research for the discovery of magnetic monopoles is ongoing. Once they are found, that has a lot of implications in Physics.
On the other hand the electric field lines start or end at a point (i.e. charges). The figure below shows that the electric field lines through the Gaussian surface enclosing the charge is not zero. But if the closed Gaussian surface do not enclose any charge but experiences electric field, the total field lines entering the closed surface must come out of the surface and the electric flux is zero (it is illustrated in electric flux article).
For a closed surface, the outgoing magnetic field lines are equal to the incoming magnetic field lines, so the total field lines passing through the surface is zero, and hence there is no flux. The Gauss's law in magnetism states that
GAUSS'S LAW FOR MAGNETISM: The magnetic flux through a closed surface is zero.
Mathematically, the above statement is expressed as
\[\Phi_B = \oint \vec B \cdot d \vec A = \oint B\,dA\,cos \theta = 0\]
where $\Phi_B$ is the magnetic flux, $B$ is the magnitude of the magnetic field, $dA$ is the element of area of the enclosing surface and $\theta$ is the angle between the magnetic field and area vector (see magnetic flux for details).