I learned French, German and Italian to a good level at school and then by working there in my early 20s. Some decades later, I don't speak them that often but sometimes at work with customers. I am still pretty good in all 3, and a day or two in country polishes off the rust, e.g. on holiday, though of course not back to my highest level.
I later tried to learn Spanish - (similar to French/Italian) but couldn't get it to the same level - easy come, easy go. Long term interest in Aikido lead my to attempting Japanese - but again it's never stuck. At university took a course in Russian - made good progress for a year and then left it - all gone!
So for me it's a combination:
- learning to a sufficient level,
- with consistent effort at the time (some level of immersion)
- it is easier when brain is younger!