this is because they had made a breach with allah and his messenger. he who makes a breach with allah and his messenger indeed allah is stern in retribution.
ذلك بأنهم شاقوا الله ورسوله ومن يشاقق الله ورسوله فإن الله شديد العقاب