The rogue scales well, yes, even though it doesn't get an extra attack, but it relies heavily on being able to get sneak attack. The most effective way to take the teeth out of a Rogue is to deny them sneak attack somehow.
Rogue actually only gets one less ASI/feat than
Fighter, which is one more than most other classes, so they are in a good place for bonuses.
As for Ranger, well... erm.
Beast master Ranger and the lack of scaling for companions has actually been a big issue for a while. Ranger itself has gone through the most revisions of all the PHB classes. The Tasha's sourcebook provided the first formally published revisions, and gave them a leveling option for the animal companion. I'll admit, I haven't played around with BG3 Ranger that much, as I don't really like their homebrew subclasses, but this is an issue shared with most of the pet and summoning classes from the PHB, it wasn't until later that we got summons with scaling.
So, yes, unless Larian has implemented scaling summons/familiars/companions, your imp will be much less effective at level 15 than it is at level 4, and that is unfortunately how it works.