This may be a bit of a tangent, but I can't help noticing your opening line here:
A lot of books and movies sucks because they are too funny. Although their genre is a mystery or thriller.
Which is rather a blanket assumption that could easily taken as insulting to wide swaths of genres/books and their fans.
And in another thread, on describing never-before seen creatures, you started out with the similarly-questionable assertion:
I think there is no difference between a story for kids, sci-fi or fantasy.
... which sort of comes across as a smack to the face of SF/F writers and readers, regardless of whether it was intended as such.
I might suggest you pause next time and reconsider your words, which are all we have to go on - we can't see facial expressions or hear tone of voice, after all, just the strings of letters you arrange on the screen. It's becoming a trifle abrasive, and adds nothing to your question. Lead with your question, then perhaps mention how you've had trouble finding examples that work for you to learn from. As for the blanket assumptions... maybe back off a bit?
As for your question, many mysteries and thrillers use humor to alleviate stress and change mood, as unrelenting tension, like a symphony with one note, would grow tiring, then quickly turn annoying, then likely lose its audience. Humor is also a very human reaction to intense situations, a stress reliever, like the way some people find themselves giggling inappropriately in disastrous situations. I understand that many people in law enforcement and medicine and other stressful jobs can develop black senses of humor to help cope with their situations... and black humor doesn't always translate well to those outside the situation, who may not see anything particularly funny about it, which may be why some audiences have trouble connecting with it. Writing good humor in general, even outside mysteries and thrillers, can be a greater challenge than straight-up writing, IMHO, just because humor is so particular, and what one audience finds hilarious, another will find bland or just plain won't connect with.
If you have trouble with this, and can't find any written or filmed examples of humor in mysteries/thrillers that work for you, maybe it's just a technique that you don't connect with, and shouldn't force yourself to use. It's just one tool in the box, after all.