In the story, Sonic becomes a werehog because of Eggman’s actions. The Chaos Emeralds’ power is disrupted, and Sonic is launched into space before returning to Earth.
The transformation is tied to the environment. When the sun appears, Sonic returns to normal, but when the moon rises, he changes into the werehog form again.