A good analogy for the difference between the two can be given in terms of two other examples of anomalies, that are possibly more familiar.
Consider a field theory with a global symmetry, take $U(1)$ for simplicity. At the classical level, the equations of motion lead to the existence of a conserved current (Noether's theorem).
At the quantum level, the conservation of the current is valid as an operator equation, namely it is valid in correlators at separated points. The two effects, related but very different in nature, that are referred to as anomalies, are:
1) There can exist contact terms in correlators (i.e. terms that are non-zero only when two or more of the operators in the correlator are evaluated at the same point) that do not respect the operator equation. In 4D field theory this typically happens in correlators of three current operators. This is what sometimes is referred to as an 't Hooft anomaly. It does not represent a breaking of the symmetry, because the conservation of the current operator is still valid at separated points, and one still gets a conserved charge. However, it leads to interesting constraints (the coefficients of such contact terms must match between the UV and IR, if the symmetry is not broken along the RG flow).
2) There can be quantum effects (you can think about them as loop corrections, assuming we are in a perturbative setting) that violate the operator equation even at separated points. In this case the symmetry is broken, much like if you add a term in the Lagrangian that does not respect the symmetry. There is no conserved charge any more.
The relation between 1) and 2) can be explained in a slightly refined example. Take the global symmetry to be $U(1)^2$. Than you could have an anomaly of type 1) in a correlator involving one current of the first $U(1)$, and two currents of the second $U(1)$. Now suppose modifying the theory by gauging the second $U(1)$, i.e. coupling the current of the second $U(1)$ to dynamical gauge fields. In the new gauged theory, the first $U(1)$ is broken by an anomaly of type 2). The divergence of its current is now non-zero, and given by the Pontryagin density of the gauge fields of the second $U(1)$.
The first example of trace-anomaly that you discuss is the analogue of 1), while the second is the analogue of 2), when instead of a global $U(1)$ we consider the dilatation symmetry. The first example does not represent a violation of the symmetry, it is just the statement that certain contact terms in the correlators with multiple insertions of the energy-momentum tensor are not compatible with the traceless-ness condition. The second example instead is a genuine violation of the symmetry. The analogy with the $U(1)$ symmetry does not go through when we try to relate 1) with 2), because the equivalent of "coupling the current to gauge field" would be introducing dynamical gravity, which brings us away from the domain of quantum field theory.
This analogy becomes very concrete in supersymmetric theories. There, the energy-momentum tensor belongs to the same multiplet of the current associated to the so-called R-symmetry. Supersymmetry relates the 't Hooft anomaly of this current to the first kind of trace-anomaly that you discuss (i.e. they have the same coefficient). Moreover, when dilatation symmetry is broken by a gauge coupling via the trace anomaly of second type that you discuss, then the current has an anomaly of type 2). Again, the trace anomaly and the current anomaly have the same coefficient by supersymmetry.