When you connect a ball bearing to a couple of magnets like that, it becomes magnetic too, for as long as it's connected. However, it's not as magnetic as the actual magnets. The same happens when further balls are connected in a row, but each is less magnetic than the one before.
When a ball hits the back of the structure, the energy is transferred down the line to the last ball, which is free to move forward - and is able to do so at great speed due to the fact that there isn't all that much magnetism holding it back. As more balls are fired off, the energy has to travel through fewer balls, resulting in more energy being put into the resulting motion - but there's also more magnetism holding back the ball that gets shot forward.