Tricky questions, what with humor being such a subjective and wily beast.
Only thing how-to I remember reading about writing funny is a single chapter (the 11th) from Dwight V. Swain's Creating Characters: How to Build Story People. Been so long since I read it that I don't recall what it says, but might be worth a look. I'll give it a read this evening.
I do inject a ton of humor (or attempts thereat) into the majority of what I write, but I've never really sat down to figure out how the sausage is made. I personally think it's something I'm better off not trying to dissect, instead relying on instinct and my own sense of humor; I'll happily risk whiffing or ending up amusing only myself.
So no dissection, no blueprints, but nobody said anything about pondering and philosophizing.
For comedy works I like to first and foremost lay down a foundational atmosphere, a vibe if you will, where humor naturally thrives. Then I steer hard towards the absurd, the silly, the whimsical. I get a lot of mileage from cranking up the eccentricity on a majority of my characters; there's great comedy to be found in the interplay of people who are strange in radically different ways--for an absolute masterclass in how to do that, see Mevyn Peake's Gormenghast series, which among its many other qualities can be hysterically funny.
I find it funny to stretch quirks to their extremes, then take it a bit further. I like to mix far-out, cartoonish personalities with relatable, realistic human foibles within a single character. You know, that thing Terry Pratchett does so damn well.
I think good humor is built on a certain irreverence, a contrast, and an element of surprise; to my mind the best jokes feel a bit like an ambush. I like to look for humor in unusual places, finding laughs in things that aren't inherently funny, or even quite tragic. I don't ever take my work too seriously, though I treat it with sincerity and respect.
I think it's important to also mix up the types of humor you put in. That goes back to the element of surprise: I want my readers to feel like something is going to be funny very soon, but not know what or how or precisely when. I do try to make each major character (the ones meant to be funny, anyway) represent their own brand(s) of comedy, be it slapstick or deadpan sardonicism or charming cluelessness, so that whatever funny thing results from them being them seems obvious and just right in hindsight.
But yeah, mainly I try to just not think about it, at least not when drafting. I write the other stuff, and humor finds its way into the cracks whether I want it to or not. Probably better to practice writing humor than reading about how to do it, but maybe best off all to do both.