It is mainly light placed in their hearts from Allah (swt). To have strong memory is possible and a number of recommendations exist.
Please check this link
https://www.al-islam.org/pursuing-excellence-guide-memorising-holy-quran-sl-al-hakim/part-2-how-memorise-holy-quran