The term defense mechanisms fit Freud's original concept of ego defense mechanisms against anxiety, and this is one notion that holds up better under modern scrutiny than many other Freudian ideas. They're not always about defending against anxiety, though. It might be time for us to start calling them something else. If these behaviors are real and important aspects of human experience, then the ghost of Sigmund Freud does not own them.
Adaptation mechanisms might be more appropriate. They're about adapting to life and functioning in this world. The term coping mechanisms, while more positive than defense mechanisms, nevertheless suggests that these actions are all about dealing with difficulties and paints every situation as a problem. Although a person conceivably could view everything we face as a problem, that's not the healthiest point of view. These adaptation mechanisms are not necessarily defensive or even offensive.
Humor can be defensive, certainly, but defense is not its only motive, nor is anxiety its single inspiration. Lapsing into the state of dissociation commonly known as highway hypnosis, daydreaming to the point that you realize you don't remember the last ten miles even though a disconnected part of you drove the car, might prevent boredom but is not driven the same way as "going to your happy place" to escape mentally from torture.
This struck me, of all times, while I was writing recently about the value, the psychological function and benefits, of cosplay (costume play), so I'll return to this shortly by using the so-called defense mechanisms (adaptation mechanisms!) to look at what might be right or wrong with coplaying, with the cosplay community, and with the range of reactions to the television series Heroes of Cosplay. I bring this up now, though, because this basic idea is not about cosplay or any other specific topic to which we might apply it.
In countless areas of life, the defense mechanisms first suggested by Sigmund and then defined more thoroughly by his daughter Anna Freud are not always defensive.