To quote Animal Crossing Community's Heatran:
What you do is, drop the items off, then the host ends the game. As it saves, [the visitor turns] off the wireless via switch on 3DS. Bam. Duplicated. Cloned.
While I've not replicated this myself—too wary of messing up my save files—I've received a number of reports from friends who have verified the glitch. Tiny Cartridge says that the timing is tricky to nail, in case you're going to try to replicate this. I wouldn't, but! The glitch exists, and it might explain why sometimes you and a friend mistakenly end up with the same item.
New Leaf duping glitch discovered [Tiny Cartridge]