Well, "The Apple" featured cartloads of quite comical deaths (redshirt replaced by a stain on the ground) at the start, and lots of sex education -themed giggling later on, plus the destruction of a way of life via the destruction of a papier-mache monster. It's not as if the writers or the directors really felt the need to steer away from "mixed bag" type stories... To the contrary, it seemed that there was often a drive to insert some comedy to overtly somber episodes.
Also, the coda to an episode was rather seldom in the mood of the episode itself anyway. But it always served the higher purpose of making it clear that our heroes would face no consequences of any sort, and there would never be a sequel. The ability to alter history discovered? "Let's get the hell out of here." Kirk is under such a strain that he breaks into a sobbing fit over a fembot (or perhaps her master and creator?)? "Forget."