Definition:
Flux by definition is the amount of quantity going out or entering a surface.
Intuition:
In the above diagram, the black line represents the surface for which the flux is being calculated and the red lines represent the direction of the flow of a quantity.
In the above diagram, the quantity represented by the red lines are moving parallel to the surface. The quantity is not leaving the surface nor is some quantity entering the surface. Therefore, the flux is zero.
In the above diagram, the quantity represented by the red lines is leaving — or entering depending on your perspective — the surface. Therefore, there is a net flux through the surface.
Mathematical definition:
A vector dot product gives you the projection of a vector along another vector. The area vector is defined as the area in magnitude whose direction is normal to the surface.
Consider the following:
$$\phi = \vec{a}.\vec{b}$$
The above equation gives the amount of $\vec{a}$ that is along the direction of $\vec{b}$ times the vector ${b}$. It is equivalent to taking the scalar projection of $\vec{a}$ and multiplying it with the magnitude of $\vec{b}$.
As the flux by definition is numerically equal to the amount of quantity leaving the surface, we are concerned with the quantity passing perpendicularly through the surface. In this situation, the dot product helps us implicitly mention the above fact.
$$\phi = \int\vec{E}.d\vec{A}$$