Normally, the causes of boredom can be due to the brain's own mechanisms, and circumstances from outside. About these reasons, wrote brilliant writers - Dickens, Goncharov (Oblomov), scientists, Nobel laureates (Ivan Pavlov) ... And scientists and writers took into account the genetic characteristics of the individual, the features of human education, the features of the formation of the worldview, goals and incentives in life. I'm sure that in extreme situations that threaten the life of a person, a person with normal psyche will never experience boredom.
It seems to me that boredom is the opposite of flow for the brain. It doesn't really have a specific mechanism but likely arises from the attentional circuits when a person is asked to devote their attention to something that they are do not find interesting or stimulating or when the environment lacks any stimulus that attention finds stimulating and so is in a continuous search loop.
This article describes boredom in terms of attention. No room to summarize here but very comprehensive article including extensive theoretical description along with explanation of brain mechanisms.
Article The Unengaged Mind: Defining Boredom in Terms of Attention
This article contextualizes these mechanisms in the default mode network.