So you'd rather Solgaleo just be a boring stoic legendary as usual? Having it show affection to Ash and co is a way of showing that it's still the Nebby they know and makes us the audience still like it. That is in no way "jammed in comedy".Well SM also adds comedic moments even in serious moments, so the Team Rocket part just added unwanted comedy in the episode. Like Ash-Solgaleo moment clearly had comedy jammed into it.
Besides, what's the need of comedy in such a serous episode of the Aether arc leading to the climax?
This may be a more serious arc but that doesn't mean it has to be completely serious, think about most adventure movies out there (especially ones aimed at kids), they maintain a tone that doesn't take itself too seriously and only get fully serious when there's an emotional demand for it. Something like, I dunno, The incredibles, where they're fighting for their lives but there's still time for jokes. Looks like next episode is going that route, and that's the way it should be, this is still Pokemon, it's silly no matter how serious you try to make it seem. Only when we focus on Lillie and Gladion confronting their possessed mother should we get into super serious mode.