This is because if you have a term in the Lagrangian that is proportional to $A_{\mu}A^{\mu}$, with some coefficient in front of it, then its coefficient is going to automaticlly be considered the mass of the gauge field $A_{\mu}$ (squared).
The term proportional to $A_{\mu}A^{\mu}$ breaks gauge invariance because if you apply a gauge transformation, i.e.
$$A_{\mu}\rightarrow A_{\mu}+\partial_{\mu}\lambda$$
then the Lagrangian peaks up some extra terms and, therefore, can not be considered invariant under the abovementioned transformation. The physics, then, or equivalently the equations of motion, change
$$\delta\mathcal{L}\ne0$$
I hope this helps
Edit#1: It has occurred to me that your question is "why is the coefficient of the quadratic term in the Lagrangian considered the square of the mass of the gauge field?" The answer to this comes from dimensional analysis. Each of the fields $A_{\mu}$ has units of mass. Therefore $A_{\mu}A^{\mu}$ has units of mass squared. The Lagrangian (density) has units of mass to the fourth power. So, the coefficient accompanying $A_{\mu}A^{\mu}$ has units of mass squared.
Edit#2: I will rephrase because @Avantgarde's comment has indeed a point. The fact that we usually (and sometimes naively) assume that every factor, accompanying the quadratic terms in the Lagrangian, is indeed a mass term is wrong (despite the fact that it is some sort of mass, since it has units of mass). The correct phrasing would be: if I want to appoint a mass to the gauge field, then the $\underline{\text{only}}$ way to do it is by adding a quadratic term with some coefficient to the Lagrangian. That coefficient is the square of the gauge field's mass...