It's a portable teleporter.
Teleportation technology has been present in every Pokemon game and is occasionally talked about. A used Pokeball doesn't actually contain a pokemon, it's a teleport sender/receiver with a unique tag used to identify who the Pokeball belongs to and which Pokemon is in it. Boxed Pokemon are kept in a state between teleporters. That's how a caught Pokemon can be sent to the Box, why a Pokeball on caught Pokemon doesn't work and why you can't switch the Pokeball of a Pokemon: If you could, it'd harm the business model of Devon and the Pokeball company in Kalos.