Your two examples are easy. If you add 'ly' to a word, you add one 'l'. If there was an 'l' already on the word, this results in two 'l's. If there were two 'll's on the word already, you don't triple the 'l', but just add 'y'. (quick → quickly, real → really, full → fully, medical → medically, easy → easily, brave → bravely, dynamical → dynamically). In general, however, there's no rule.
Sometimes, you have to add 'ally' to a word where you can't simply add 'al'. For example, 'specific' goes to 'specifically', but the word 'specifical' is no longer used. In that case, you add 'ally' with a doubled 'll'.