Humor is thought to be a coping mechanism by behaviors studies experts (ironically those who study humor tend to be very unfunny. The observation is that scientifically studying humor tends to operate like disecting a frog: It's certainly possible and frequently done, but the subject of the study (humor or the Frog) tends to be destroyed in the process.
That said, many a non-comedy offer a plethora of humerous moments, be they dark or just wacky. Ask a Lawyer what the best Legal film is, and you'll get "My Cousin Vinny" which is a comedy about a lawyer who is defending two clients in a capital murder case (you might ask, where's the funny in that? But the central gag is that it's mocking a culture clash between Vinny, a man so full of Brooklyn Italian American Rage, he could only be played by Joe Peshi, and the jurisdiction the case is in, rural Alabama. The legal humor is more from Vinny's lack of court room decorum but over abundance in skill. He doesn't look the part of a competent defense attorney, but he can find the whole in any story like the best of them).
Other examples are Marvel Movies which are humerous. If first prompted for a genre, they're clearly Superhero-films. But Marvel doesn't approach them in that way. Marvel movies tend to be genre films first, featuring a superhero. Iron-Man is a Tech Thriller, Captain America is a Period War Film, and then a political action-spy thriller. Thor is an Urban Fantasy as seen from the point of view of a character more suited to a Sword and Sorcery Fantasy and elements of Planetary Romance (especially in Ragnarock). Guardians of the Galaxy is a Space Opera with a helping of Comedy because there is no other way to do a foul-mouthed Racoon and a tree who's native language comprises of four words yet is still understood (ala Chewbacca's grunts). Ant Man was sold by it's director as a heist film, Ms. Marvel was a 90s-action throw back (it's casting and alien menace made for plenty of homages to 90s hits). Dr. Strange is a more straight Urban Fantasy ala Harry Potter. Spider-man were homages of teen dramas and comedies (Home coming and Far From Home respectively). The second film also includes elements of a Road Trip film and mocks the Infinity War films, by showing some more down to earth repercussions to Thanos' snap (almost all played for humor). The Avengers Films are really the only straight superhero films, but they require humor because the characters are all out of genre. And Infinity War was a Superhero film from the Villain's Point of View (Thanos has more screen time then Iron Man and Captain America combined). Humor works it's way into all the films examples to mesh with unique premises. Iron Man's humor is built around Tony being anything but the humble Clark Kent dual identity. Either hero or civillian, Tony is always flashy. Captain America gets a lot of humor playing of the characters moralistic view of the world, where in the first one, he gets a lot of jokes at his expense in that he's used for propaganda but not actually fighting the good fight. The sequels play a lot on the fact that his black and white view of the world is naive for his genre. Endgame puts this front and center by showing a recently thawed Captain America fight one that has become a lot more jaded in a short decade... and who finds his past self annoying to boot. Guardians of the Galaxy draws much of its humor from a human from constantly pointing out that theses personalities are not what comes to mind when you think Guardians of the Galaxy and that they are more of a dysfunctional family then the best heroes of space (one of the enduring humorous elements of Fantastic Four was that they behaved like a nuclear family with misbehaved children and clueless parents then a team of heroes). Thor's humor is based on his High Fantasy hero bravado meeting an actual real world response. It helps that his constant villain is a trickster god.
Again, none of these are billed as comedy, but none of them are devoid of humor. In fact, Endgame was probably the least humorous marvel film to my reconning, and even then, it's entire second act is mocking it's previous works with glee.
And that goes in reverse too. Some comedy films are done in a "laugh with, not at" style that makes the humor based around the audience's familiar genre getting a loving prod of laughter. Ask any Star Trek fan what the best star Trek film of the 1990s was, and you won't search long until you find someone who earnestly shouts "Galaxy Quest" as his answer, which is a film that mocked Star Trek's well known cliches and back stage drama, but the conflict of the story centers around the show's disillusioned actors coming to realize that the show was loved, warts and all, because the premise of a bright future where people worked together despite cultural differences was something worth fighting for. A more modern Star Trek Spoof, "The Orville" takes the premise in that while Star Trek is at times too flawless, it's optamistic outlook and parable like stories allowed people to re-evaluate their views on the subject from a point of view removed from modern politics. Much of Orivill's humor is based on people of the future finding positive ideals from unlikely sources the audience is familiar with. For example, who's the Captain's role model from fiction, a humble leader who leads a motley crew of characters governed by their odd personality traits? Kermit the Frog. The humor is Kermit is not the first person called to mind when prompted to name such a character... but it's not wrong to describe him like that. In another episode, one alien character does a complete 180 after watching an inspiring film about an unlikely hero who defies discrimination and comes to a place of leadership in the very society that scorned his existence... Rudolph the Red Nose Reindeer (the claymation film). Another alien character, leads the oppressed women of her planet to demand equality by quoting a noted feminist poet from earth's diverse history of works, and dramatically recites the refraim to Dolly Parton's "9 to 5" before the Union of Planets' congress. Again, the gag works because Dolly Parton is not thought of as a feminist thought leader by the audience... but "9 to 5" is all about a working class woman who's boss fails to acknowledge her talents while, if I may be so blunt, only acknowledging her as a pair of tits. The humor is that Dolly Parton is quite well known for her assets, but that doesn't diminish that "9 to 5"'s message is not only profoundly motivating to someone who's similarly oppressed, but that the laugh relies on the audience taking the same attitude as the Boss of Dolly's work, judging her on the presentation of the message, not the message's strength. Like Kremit and Rudolph, the joke is written to put the message in mind. The Captain of The Orvill is not a brave hero in the fleet flagship leading the best of the best at his crew, he's a man who has to lead a group of people with issues and inspire them to do something more. Like Star Trek before it, Ruldolph takes the alien to a place that explains that just because some one is physically deformed, it does not mean one is incapable of being a good person and does not automatically convey weakness. For the leader of oppressed women, she has no mental image of Dolly Parton and is thus able to accurately point out that by laughing at the joke, the audience have judged Parton on her appearence, not on her merit. Parton's attarctive appearance and southern twang are not the appearence of a wise preacher of wisdom to most humans watching the show. But if such a person says something that is an accepted truth, does their appearance make it less so? After all, to the people who loved Star Trek, did the fact that the ship wasn't real and the daring heroes were actors playing pretend detract from the profound truth they spoke? Picard's famous "With Each Link, the Chain is Forged" soliloquy is just as valid a point as "They just use your mind and don't give you any credit, its enough to make you crazy if you let it."
The joke then asks the serious question: are you laughing at our bizzare comparison... or your own small mind for never considering that it's a sound argument? And if that's the case, what other ideas do you scoff at because of the people discussing them?
As a loving family man who had a gift for bringing out the best in other people once said, "A laugh can be a very powerful thing. Sometimes, it's the only weapon we have." He was also a character from a comedy blended with a serious genre... and is considered a resounding successful example of both of it's genres.