When we commit a mortal sin we lose our state of grace. What would be what leads us to keep on praying, doing good deeds and repent from what we did?
The desire to obtain eternal life.
If I commit a mortal sin, I lose sanctifying, or habitual, grace, not all grace, whereas prayer, repentence and other good deeds are done with the help of actual grace.
It is not necessary to be in a state of sanctifying grace to do an action with actual grace.
I hope this was helpful,