That's not how it works, actually! There are a few different classifications for Pokémon like this, and only some of them are banned.
The first two are officially lumped together under the umbrella of Legendary (with some exceptions), but they're actually considered distinct groups for the purposes of rules.
The first group is "minor" Legendary Pokémon - generally the ones with base stat totals of 600 or less (including Cobalion, Terrakion and Virizion, which have 580), except for the ones like Zygarde and Necrozma that have forme changes to make them stronger. The games also treat Ultra Beasts like part of this group even though they're not officially considered Legendary.
These "minor" Legendaries actually
aren't banned from any standard competitions - the only time their status even comes up at all is in rare special cases (like, there was this one special Battle Spot tournament in ORAS that
only allowed Legendary and Mythical Pokémon, and these were legal for that purpose; also, the GTS in Sun and Moon let you filter out requests for these Pokémon), but it's usually not to ban them even then.
The full list of these so far is as follows:












































Incidentally, Kubfu and Urshifu are two of these - as soon as Isle of Armor Pokémon are made legal, you should be able to use them freely!
(See how Mega Latios, Mega Latias and Regigigas are here? There's a reason for that! Despite their high stats, Mega Latios and Mega Latias have to hold items to change form, which means they can't hold more useful items like Life Orbs or Leftovers - even though it looks like they have much higher base stat totals than the rest of the Pokémon here, they aren't far ahead at all, and Mega Latios has even struggled to compete with regular Latios in the past. And Regigigas is just a sensible inclusion - thanks to Slow Start, it's one of the weakest Legendary Pokémon there is, so its above average stats almost don't count!)
The second group is also a set of Legendary Pokémon, but they tend to be much stronger (for comparison, on Smogon, all of them start in Ubers and are only even considered for lower tiers in very rare cases). These ones generally have base stat totals of 670 or higher, or - like Zygarde and Necrozma - can reach formes that are that strong without having to hold an item.
These are still Legendary Pokémon, but they're
also known in official rulesets as "Special Pokémon" or "Restricted Pokémon," and
they're the ones that
tend to be banned or restricted (hence the name).
Generally speaking, you can remember the list of Restricted Pokémon pretty easily once you know about them - they're usually the most "important" Legendary or group of Legendaries from each Generation, and there tends to be only one set from each region. Other than Mewtwo, all of them are either the mascots of games or part of a set with something that is!
The full list of these so far is as follows:




































We don't know for sure, but the official site seems to hint that Calyrex might join their ranks when Crown Tundra comes out! They draw attention to the fact that it's the "cover Pokémon" of the Expansion Pass in the same way that most of these are the mascots of various games. You can probably expect it to be banned from regular formats, but it might show its face in the VGC in the future next time that Restricted Pokémon are allowed!
(These are the same Pokémon that are banned from facilities like the Battle Tree! A lot of people make the mistake of thinking the bosses there cheat because they use Legendary Pokémon, but the Trainers only ever use the same ones the player can bring - which is actually another way to remember it! You see non-player characters using Pokémon like Suicune and Thundurus all the time in the Battle Tree, but can you even picture a random Trainer throwing a Kyogre at you?)
The third group is more distinct from the others - officially, they're not Legendary Pokémon at all, but they used to be called that in some regions before they had a name of their own.
(They were actually never the same thing in Japan - calling them Legendary is something the English translators made up early on, and then it stuck for a while until they finally got their own name. Since then, they've gone out of their way to separate the groups a handful of times.) These are
Mythical Pokémon, and they're
almost always banned from official competitions.
The main deciding factor for something to be a Mythical Pokémon actually has nothing to do with stats - the group includes Pokémon like Phione, all the way down at 480 base stat points, through Arceus, which has 720. Actually, it's just a matter of availability: all of these are Pokémon that were first released through limited-time events rather than being a normal part of the game, and most of them have stayed that way.
Since many players have no way to get most of these, even if they buy every Pokémon game and do everything possible,
they're almost always banned from official rulesets - the only exceptions tend to be silly, "just for fun" competitions like the Halloween celebration Ultra Spooky Cup or the "No Holds Barred" event from Ultra Sun and Ultra Moon.
There have been some years in VGC when even Restricted Pokémon were allowed (usually only two per team), and in a setting like that, you might think something like Keldeo would be totally fine - it wouldn't be doing anything nearly as broken as Xerneas or Primal Groudon, right? But it's actually not a power issue at all - if something like Keldeo just happened to be useful, and there was no way to access it, it would be a huge disadvantage to players who didn't start playing years ago and get a perfect one back when Keldeo was around. That's why Mythical Pokémon aren't options in most official formats! Even in a competition where you can use Xerneas and Primal Groudon on the same team, you can probably expect to have to leave Keldeo behind.
(Smogon formats don't tend to make the same distinction at all - that's because battles here are done on a simulator where availability doesn't matter! If everyone can bring Mew, it's no problem to treat it like any other Pokémon and tier it based on its strength rather than its Mythical status. Of course, some of them really are just that strong - there are more than a handful of Mythical Pokémon that have been banned even on Smogon.)
The full list of these so far is as follows:





























Zarude will also be one of these when it's released - you won't be able to use it in most official competitions even once it's out. (On the bright side, its signature move looks pretty much designed for raid battles, and I bet people would appreciate you bringing it to one of those if you're looking for something to do with it!)
Hopefully that's some help!
If that was too much, the short answer is "Cobalion, Terrakion and Virizion are Legendary, but they're not the kind of Legendary that gets banned." C: