I believe this is caused by a combination of the internal terminal in the hole in the plastic end where the battery terminal is supposed to seat being seated a little to far back. This appears to happen over time and can happen faster when the AA batteries you use have a higher positive terminal “nub” than others. The rechargeable batteries I had switched to started having issues and I switched to standard AA batteries but eventually the issue came back and then neither type of batteries worked. The foil solution is either a solution or a stop gap measure until you can get inside and remove the battery/spring section to re-seat the internal terminal in the hole again.
I’ve just been through the above bits to get at it and decided to put it all back together and go with the foil solution myself.
Hope that all helps fill in some gaps :)