Humor is incorporated into your books, and a lot of people think this is the hardest thing to do. Unexpected things are funny. Surprises make people laugh. Opposites are funny. Exaggeration is really funny.
Unexpected things can feel disconnected.
In other words, there IS no formula to writing humor. You just have to be funny and know when you see funny. And you have to know when something ISN'T funny, too. That can be even harder. If there were a formula for people to be funny, everyone would be laughing and the world would be different.