God will allow temptation for us to undo sins in our lives and break habits of sin. A priest told me this and it is a simple and good truth.
The body adjusts itself to the operations of the soul, and chemically a body readjusts to new stimuli of turning against the sin.
We actually have to turn away from sin physically, emotionally, and spiritually. As humans, we are body and soul, so we are tempted in both for most sins. There are triggers and to break habits of giving in to triggers, God gives us temptations to make "our inner person strong". We can be addicted to certain sins, even thinking negative thoughts. God can change this is we allow Him to enter into the memory, understanding and will.
Demons affect the cogitative powers.
When we decide or judge on something, we create a habit if we keep doing something...this is what St. Thomas calls the "intellective memory" in the positive intellect. This process works on those powers in the inward man, referred to in St. Paul's epistle as being made strong in grace. The sensitive memory is in the imagination.
Thank God for priests who have studied Thomas Aquinas. They are few and far between.
Ephesians 3:16Douay-Rheims
16 That he would grant you, according to the riches of his glory, to be strengthened by his Spirit with might unto the inward man,