This is what we call muscle memory. Once you learn a new riff or lick, you muscles needs to adapt to it. They need to learn when to contract and when to release. Once they learn it and it becomes "memorize" and the next time you play it, you don't have to think about it.
This is why we always say to start an exercise very slow and increase in speed as you go. Playing at slow speed insure more accuracy while your muscles are learning how to play the lick or riff.