I explained how this works with voodoo a couple pages back. It does not count as damage.
As for scarab, it switches the stats like normal, and the max HP is set to the new value. It would still get +1 defense for each new scarab, but it would have a lower defense than the others permanently.