It's deliberate. The immunities to lightning and thunder bumps up the effective HP to 345 (though without them the resistances bump the HP to only 288, and I'm thinking they used the 288 because of how specific the damage immunities are), while having 4 saving throws bumps the effective AC to 14. This puts the defensive effective CR at 17 with immunities, 13 without. Two Lightning Swords and a Thunderbolt Legendary Action puts the damage at 102, or CR 16. However, having a +14 to hit raises the offensive CR to 18.
So even with it's low AC, the math works out to about CR 15-16, depending on the impact of the immunities.