Hamster toys have complicated built-in circuits that record and play the notes back in a shrill, critter voice. As these circuits have limited memory, they record voices temporarily. Once played, the information is deleted.
Along with this, hamster toys are designed to be sensitive to touch. The receptors on the circuits are sensitive to touch. They immediately turn on when touched and shake, move, or nod as per the built-in program.