How can I stop forgetting spells in ADOM?
Unfortunately, you cannot. Each casting of your spells from memory costs you spell memory independant of PP cost. For other casters thus is rarely an issue as you can learn (or cast!) spells from books, and your spell memory for common bolt spells can reach the thousands.
However, elementalists cannot do this - they only gain spell memory on level-up, and cannot use spellbooks.
Raising literacy does not help you learn spells as an elementalist. Even a huge Learning score won't help. The sole determining factor is character level: you will gain a multiple of your level (plus a constant) in BH and your bolt spells, and a fraction of your level (capped at 5 or 10, depending on the spell) in the rest, on level-up.
Be judicious with your spell useage as an elementalist. You may want to practice your melee/ranged combat skills, and make sure you use the right spell on the right target.