From Nookipedia, the Animal Crossing wiki
Candy is sold throughout October in preparation for Halloween. It appears in Animal Crossing, Animal Crossing: City Folk and Animal Crossing: New Leaf. It is a sweet wrapped in a red, yellow, green or blue-striped wrapper. On Halloween night, from 6 P.M. until 1 A.M. the next morning, in Animal Crossing villagers dressed as Jack, the Czar of Halloween, chase the player in order to receive candy. If the player refuses to concede candy, the clothes or inventory items are transformed. When players give candy to Jack himself, they receive a piece of the Spooky Furniture set. On Festivale, Pavé will also ask for three of a certain colored-wrapper of candy, which will reward the player with Pavé furniture.
Candy, along with its corresponding event, furniture set, and holiday character, is absent from Animal Crossing: Wild World. They all make their return in Animal Crossing: City Folk. Candy can be given to the player by visiting the houses of the villagers who stayed in on Halloween night by wearing a costume. Also, during the new event, Festivale, candy can be won from villagers in luck-based challenges except Hide-and-Seek and can be supplied to the host of the festival - Pavé. They also can be found on Bunny Day, in some eggs. If the player leaves candy on the ground, ants can appear crawling over it.
During October, Tom Nook sells one piece of candy per day in Animal Crossing: City Folk (up to five per day in Animal Crossing). It costs 100 Bells in Animal Crossing, but this was increased to 400 Bells in Animal Crossing: City Folk.
In Animal Crossing: New Leaf, candy is replaced by Feathers during Festivale, but still appears during Bunny Day and Halloween, and it is on sale at the Nookling Stores, temporarily replacing Fortune Cookies in October.