A lighthearted story is generally one where the consequences of failure are mostly the status quo. The MC isn't going to die or go bankrupt if they fail. They must have something at stake (money perhaps, lifelong dreams) but if they fail their life isn't ruined. Nevertheless, the reader wants the MC to succeed, and sympathizes with them.
Consider a story like "The Money Pit", an engaged couple naively buys a dilapidated house as-is, thinking it just needs a coat of paint and some minor repairs, and in scene after scene they realize it is worse, and worse, until they are going to give up, perhaps not get married, but in the end it all works out.
Or Brewster's Millions; the 1985 Richard Pryor version: In order to inherit $300 million, Pryor must spend $30 million in thirty days, and cannot tell anybody why he is doing it. The audience knows, of course, so it becomes very funny watching somebody desperate to unload money by the rules (a limit on charity, gambling, etc), and funny when he thinks he has made a terrible investment but it works out (so he didn't get rid of the money). A lot of reversals that make him seem crazy to other characters, but we know he is not.
But the stakes are neutral. Expected windfalls that do not materialize, in both cases. Perhaps monetary losses in The Money Pit, but nothing they cannot afford.
Once you are free of the consequences being dark or devastating, failures can be funny, as long as the consequences of failure are not life changing. If your character falls off the roof, he doesn't break his neck, he gets up and limps away and is fine in the next scene. If something explodes in his face, he isn't blinded or scarred for life. The dog getting loose causes a fender bender he ends up paying for, without hurting the dog.
The same thing can go for moral failures or cowardice: Say after causing the fender bender, the prospect of him having to pay for it makes him grab his dog and literally run away, being chased for a minute by one of the motorists. Cowardice has been played for laughs (eg Angel in the Rockford Files), as can minor violence (getting punched in the nose, falling on the ice, crashing into a tree on a bike).
The key is that the setbacks and consequences are all recoverable by the characters, things tend to stop being funny when the audience senses life-changing (or life-ending) consequences, at least for the main characters.