Pressure-induced structural transitions of the alkaline earth hexaborides, CaB6, SrB6, and BaB6, are studied theoretically using electron counting rules and density functional theory calculations. We demonstrate the applicability of gas-phase borane electron counting methods to solid-state metal borides and validate the assumptions of the rules by DFT calculations. All three compounds share ambient-pressure and high-pressure structures, but BaB6 differs from CaB6 and SrB6 at intermediate pressures. The unique BaB6 phase is shown to break electron counting rules, while all other phases obey them. This anomaly is resolved by DFT, which reveals B-Ba covalency and unusual B-B π bonding under pressure. The relationships between structure and bonding might help understanding properties of variety of borides, including the exotic behaviour of lanthanide hexaborides, and design new borides with desirable properties. Developing electron counting procedures for solids will enhance materials discovery efforts with chemical intuition.