What is Challenge Rating?
To begin, "perfectly balanced" is not how challenge ratings are intended to work. Challenge rating is described in the SRD as:
A monster’s challenge rating tells you how great a threat the monster is. An appropriately equipped and well-rested party of four adventurers should be able to defeat a monster that has a challenge rating equal to its level without suffering any deaths. For example, a party of four 3rd-level characters should find a monster with a challenge rating of 3 to be a worthy challenge, but not a deadly one. (Emphasis mine)
Challenge rating is defined by two factors: offensive CR and defensive CR. Offensive CR is determined by the maximum amount of damage a monster can put out in one round if it goes full nova and uses everything at its disposal, while defensive CR is a measure of highest possible AC and maximum hit point total, if all buffs available have been applied. These values are adjusted by any other effects the monster might have (resistances and immunities for defense, status effects, poison, or other effects for offense). Once the offensive CR and defensive CR have been calculated, they are averaged to determine the overall CR. Then, once the monster has been play-tested, the CR is adjusted to match the appropriate party level.
For example, if you calculate the CR for an ogre using the rules in the DMG, you might come to a result of CR1, but in play-testing the 5e designers found that a single ogre was too much for a group of 4 level 1 PCs, so the CR was adjusted to 2, because even though the calculations show it would be a CR1, it has high enough damage output that it could one-shot most level 1 PCs.
Why does this matter?
Now, there are, of course, many factors that come into play when looking at a party and determining what CR it can handle, but the most important are called out in the description for Challenge Rating: an appropriately equipped and well-rested party.
When you consider that magic items are entirely optional (see the DMG chapter on Treasure for details on this), it brings into question what appropriately equipped might actually mean.
For example, a CR 3 werewolf (a "subtype" of lycanthrope) has damage immunity to "bludgeoning, piercing, and slashing from nonmagical attacks not made with silvered weapons."
CR 3 is the measure of a medium-difficulty challenge for a party of 4 level 3 adventurers who are well-rested and are well-equipped for the encounter, and in this case, an appropriately equipped party will have access to magical attacks (spells or magic weapons) and/or silvered weapons.
So, you can see that magic weapons themselves do not need to be involved (and they shouldn't be required, since they are an optional mechanic), and the CR is unaffected by that fact. A party of 4 level 3 PCs who have the right gear (silvered weapons/magic) and who are well-rested should be able to handle this encounter, and magic weapons themselves have little impact on the outcome of the encounter.
Magic weapons might increase damage output and ability to hit (increased % chance to-hit and +3 DPR at most), but only slightly. However, because CR is based on the monster's AC, resistances, immunities, and damage output, it makes little difference what magic weapons the PCs have available to them (if any at all), so long as they have the means the mitigate any defenses a monster might have.
Also, note that the DMG random treasure tables contain guidelines for the types of treasure that should be awarded for an encounter of a given CR. As the party increases in level and encounter CRs increase, the tables should increase the party's power accordingly. These tables can also be used to gauge if a given item is too powerful and would change the game for the party as its current level. A +3 magic weapon at level 5 is going to have a much more noticeable impact than a +3 magic weapon at level 15, and this is generally reflected in the treasure tables.