It was not luck, or technique. It was rage-fueled Force (Dark side of it). Matthew Stover's ROTJ novelization expands on that:
A starburst of clarity blossoms within Anakin Skywalker’s mind, when he says to himself Oh. I get it, now and discovers that the fear within his heart can be a weapon, too. ...
Dooku is dead already. The rest is mere detail. ...
And all for nothing, because a nuclear flame has consumed Anakin Skywalker’s Jedi restraint, and fear becomes fury without effort, and fury is a blade that makes his lightsaber into a toy. ...
Dooku’s decades of combat experience are irrelevant. His mastery of swordplay is useless. ...Even his knowledge of the Force has become a joke. ...
But Palpatine’s words rage is your weapon have given Anakin permission to unseal the shielding around his furnace heart, and all his fears and all his doubts shrivel in its flame.
And then, to the taking of the hands:
In that pristine clarity, there is only one thing he must do.
So he does.
He decides to win.
He decides that Dooku should lose the same hand he took. Decision is reality, here: his blade moves simultaneously with his will and blue fire vaporizes black Corellian nanosilk and disintegrates flesh and shears bone, and away falls a Sith Lord’s lightsaber hand, trailing smoke that tastes of charred meat and burned hair. The hand falls with a bar of scarlet blaze still extending from its spastic death grip, and Anakin’s heart sings for the fall of that red blade.
He reaches out and the Force catches it for him.
And then Anakin takes Dooku’s other hand as well.