Natural swarms arranged from cells to herds are usually decentralized but display intriguing collective intelligence in coordinating individuals across large scales to efficiently achieve their common goals. Learning from nature may provide new strategies for controlling collective dynamics of synthetic swarms to accomplish specific functions. Here, we present a bio-inspired computational framework that steers distributed active swarms to collectively capture and merge targets via reinforcement learning. We exploit collective milling structures of natural herds to cage the targets, and adopt a switching control policy inspired by sperms’ chiral dynamics to optimize the trajectories of individuals, through which the active swarms can self-organize to enclose single or multiple distant targets in a dynamical, adaptive and scalable manner. There exists a critical swarm size, beyond which the excessive competition between agents would generate large mechanical forces, leading to capture instability but enabling the transition from short-distance to long-distance merging capture of multiple targets. This work provides physical insights into distributed active swarms and could offer a multilevel, decentralized strategy toward controlling swarm robotics in wide applications such as bio-medical devices, machine immunity, and target clearance.