It used to be a common practice for soundtracks to play “funny” music in certain scenes to, I guess, let the audience know that something funny was happening.
Some examples: at 1:55-2:08 in this clip from To Have and Have Not (1944); at 1:58-2:22 and 7:01-7:17 of these clips from the original 1960s Star Trek; and at 3:41-3:56 and 4:46-5:17 of these clips, likewise from Star Trek.
This practice has always really annoyed me; for some reason I’ve found it much more distracting than a laugh track, which I’m generally able to tune out. I’m not sure at what point in screen history this stopped being common practice, but I’m very glad it did.
It’s the same kind of emotion shaping that goes on in any kind of scene. What’s the point of the schmaltzy Celine Dion song from Titanic?
Other techniques can be just as annoying, such as cutting to closeups of emotional reactions by bystanders. The filmmakers are telling the audience how they should feel about what’s happened. Some filmmakers refuse to do that. Otto Preminger and Ronald Neame come to mind. In Neame’s case, who’s side is the viewer supposed to take in The Prime of Miss Jean Brodie? Some viewers might find themselves frustrated by Neame’s impartiality. In that case, it’s lack of emotion shaping that might be annoying.