Another example: officially, you evaluate CR of spellcasting monsters on a DPR basis for the spells, but then swapping out spells has no effect on CR. (Why? It makes no sense!) Variant dragons with spells are far more dangerous than non-spellcasting dragons bit have the exact same CR.
Monster design is indeed pretty bad in 5E. That, and magic item rarity, are the two biggest issues I have with 5E. Fortunately you can still convert AD&D monsters forward.
Actually, the rules specify that swapping spells can change CR (page 5-6 of the basic DMG). Specifically, the monster has to use its most efficient damage dealing mechanism for three rounds to determine base DPR. An adult red dragon for example already has potent damage dealing capabilities. Each attack is calculated as if it hits, and each spell with a save DC for half damage are calculated using the area of effect rules in the DMG and as if all the targets made their save (what I have found from reverse engineering dragons and spellcasters). So for the adult red dragon, each round it gets 51 damage from legendary actions, after that it gets:
Round 1: Frightful Presence (needed for the bump to effective AC) + 49 damage
Round 2: Flame breath (60 foot cone = 6 people * 1/2 damage) 189 damage
Round 3: 49 damage
So the average effective DPR is 147 damage.
I don't have my books with me, but I seem to remember that dragons only get spell slots up to 1/3 their CR or something like that. Keeping with a fire theme, there is flame strike at 5th level, but it only does 28 average damage. Fireball at 3rd level is the easiest to calculate, and I am pretty sure off the top of my head that an adult red dragon would have access to it. It does 56 average damage (4 in area of effect 28 damage each, save for 1/2 damage). That is only slightly higher than the round 3 damage as it is. That would only move the average damage to 98, so not much of a difference.
Other dragons would potentially have a stronger effect. A white dragon with cone of cold to supplement its breath weapon would use 108 damage (from memory) for a round. This could potentially bump the offensive CR a step or 2, but any increase is still halved because it is averaged with the defensive CR. A concentration buff spell could boost the defensive CR and help with that overall increase in CR. The dragon's legendary resistance could also help ensure that the buff stays up longer.
All in all, I think dragons function better if the bulk of their spells are utility in nature (such as alarm to guard a passageway, but that's just me.