No you get the badge by beating them, and can battle anyone at anytime.
Ex: Water, Ground, Bug are a triad. You beat Bug with Gyarados, Scolipede, Charizard, Mew, Venusaur, and Salamence.
You'll then have to also face the Ground & Water Leaders using that same team.
Now, If you somehow cannot beat them the remaining Gym(s), you are allowed to change your team around, but at the expense you'd have to re-battle the Gym(s) you've beaten.