As a preliminary remark, note that the Tate-Shafarevich group also measures a certain defect, just like the class group. Its elements correspond to homogeneous spaces that have points everywhere locally but no global points. This is explained e.g. in Silverman.
First, let us agree that the Birch and Swinnerton-Dyer conjecture is the elliptic curves analogue of (the square of!) the analytic class number formula. Just like the latter, the former gives an algebraic interpretation of the central value of the $L$-function associated with a Galois representation (in fact a compatible family of $l$-adic Galois representations). See this MO post for more on the comparison of these two formulae.
In both formulae, a central role is played by a certain finitely generated abelian group. In the class number formula, it's the unit group of the ring of integers, in the BSD formula it's the Mordell-Weil group. Both formulae contain the size of the torsion subgroup in the denominator, and the volume (to be precise the covolume under a suitable map) in the numerator. Also, both contain some Tamagawa numbers. In the class number formula, we can only see the Tamagawa numbers at the infinite places, in the guise of some powers of 2 and $\pi$. Finally, both contain the discriminants of the number fields involved. The only other ingredient is the class number in the one case and the size of sha in the other. It is therefore natural to conclude that these "correspond to each other" in these two situations.
There is in fact a more precise correspondence, but one that is much harder to explain. Both formulae have a common generalisation, the Bloch-Kato conjecture. Under this generalisation, sha and the class number literally become the same object attached to a motive. In particular, the class number can, just like sha, be expressed in terms of Galois cohomology. This is explained in some surveys on the Bloch-Kato conjecture and on its equivariant refinement, but even the surveys have quite a lot of prerequisites in order to be able to read and to understand them.