Activity and autonomous motion are fundamental in living systems and have stimulated the new field of ‘active matter’ in recent years. Numerous investigations during the past decade have been focused on the mechanisms of active matter self-organization and generated tremendous advances. Nevertheless, the collective motion of active matter in confinement is far less understood and controlling the self-organization of active matter remains an enormous challenge. Here, by means of studying motile swimmers in bacterial communities, we sought to comprehend and control the self-organization of active matter in space and time. We found that motile cells near the edge of confinement can self-organize into two adjacent, large-scale motile rings. We also discovered that viscoelastic active matter consisting of motile bacteria and self-produced extracellular matrixes networks can self-organize into highly robust oscillatory motion in two distinct modes, namely translational and rotational modes. These findings present unique forms of large-scale self-organization and active transport in bacterial communities. The findings will also fuel the development of nonequilibrium physics and may have implications for the engineering of self-assembled microfluidic systems for fluid pumping and cargo transport.