I think the primary issue is that the Mi-24 was designed from the outset as a transport with attack capability whereas the Ka-52 was designed as an attack helo only.
The Ka-52 doesn't have to lose performance like the Mi-24 does due to the Mi-24 having a cargo/troop capacity. So like MontyB said, it's therefore able to be much smaller and with a better power-to-weight ration thus increasing performance and manoeuvrability.
The Ka-52 has also been designed to use air-to-air missiles instead of just air-to-ground weapons.