He supposedly converted to the heresy and used their theology as a means to consolidate power away from the priesthood. While I see the proto-socialist movement as a threat to any empire, it seems to me that murdering the prophet of your own religion is a major faux-pas. Any insight welcome!
Kavadh I didn't have Mazdak killed, Khosrow I did. The mazdakites supported Kavadh's son Kawus against the nobles and Zoroastrian clergy. Khosrow I destroyed Kawus and executed the Mazdakites. This was likely done as part of his general pattern of executing anyone who was a threat to his reign, though the Shahnameh implies it was done out of piety.
Source: Sasanian Persia: The Rise and Fall of an Empire by Touraj Daryaee