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.