The reason why Mojang has been taking action on these hacked clients is simply because they are violating Mojang's copyright.
There is a difference between a mod, and a modified version of a game. Mojang's EULA states that you can make mods for the game, but you can not distribute the game's binaries. These hacked clients weren't mods, they were modified versions of the game. They still had some of the game's original binaries included inside them. The way these hacked clients are able to get around that is by making injection-based clients, kind of like how Forge and Optifine work. If Forge was distributing original binaries from the game, the same thing would happen to it too.
It's not that simple to stop hackers. The only way to stop them are to ban them.
Even then, it is still hard to ban hackers. There is something known as MCLeaks, where hackers have access to almost infinite accounts. And anyone has access to VPNs, in order to bypass IP bans. Some servers actually ban VPNs in order to prevent this by installing plugins that have huge lists of VPNs. There is even a discussion thread about whether or not VPNs should be allowed on Minecraft servers.
Some people give up trying to compete with hackers, so then they become hackers themselves. Then, it just turns into a chain reaction where everyone gives up being legit and starts hacking. It's really sad, and Mojang could stop this by actually making malicious hacks against their EULA. Currently, they do nothing to target hacked clients as a whole, but it looks like this because the way they are distributed actually is against the EULA.
The last part is also not very clear and can easily be circumvented; for example, a hack that lets you give yourself items regardless of whether you can use commands - including items like TNT and bedrock? Or an x-ray mod, stated to let players find ores? What if you instead use it to locate somebody's base so you can grief it?
Also, those hacked clients are only illegal because they are entire working versions of the game, not a few modded files; basically, if you can play the game using nothing more than the mod files (without needing a vanilla Minecraft jar) it is illegal (I've seen people post entire modded jars on these forums when posting a mod they made), and they can easily get around that by only distributing the modified code that adds the hacks (I highly doubt they would have to modify every single class within the game):
You may not distribute any Modded Versions of our Game or software, and we’d appreciate it if you didn’t use Mods for griefing. Basically, Mods are okay to distribute; hacked versions or Modded Versions of the Game client or server software are not okay to distribute.
As with the above this does not prevent somebody from making a mod that helps you to grief - the only way to stop that would be to ban all mods, except for ones which are officially approved or based on an official API that makes it impossible to make a hack/grief mod; of course, either would destroy modding as we know it due to only letting you make certain changes, much like resource packs, which themselves are considered to be a type of "add-on" (the only form of "modding" allowed by many versions of the game; you won't be seeing many hackers, if any, on Console due to mods being forbidden).