Unlearning slowly is a matter of will and belief in a higher power over one’s actions than animal impulse.
I think you are conflating all brain function with intellect. That is not the case. Will and, for want of a better word, spiritthese are transcendent functions that go beyond logic and reason.
Unlearning slowly is a matter of self-calming of a person’s reactions/responses to specific stimuli. It takes time, even years; so some of the beneficial side effects are a growth of patience and self-encouragement to avoid or endure tough situations. The person wanting to change learns to shift gears mentally, not to treat every hard-on as a critical emergency demanding response. As time goes on, abstinence from the “undesired desires” becomes learned in place of the impulse to seek gratification.