From the Minecraft Wiki: When the spot a cactus is placed in becomes unsuitable, such as when a block is placed next to them or their own sand block underneath is harvested or falls, the cactus block and any above it collapse into blocks that can be collected and placed again.
From the Minecraft Wiki: When the spot a cactus is placed in becomes unsuitable, such as when a block is placed next to them or their own sand block underneath is harvested or falls, the cactus block and any above it collapse into blocks that can be collected and placed again.