So the reason why they don't immediately ban every single time they detect a cheater is because that gives programmers ways to avoid detection better the next time.
So for example:
Cheating program uses A, B, C, D, E, and F methods of altering the game or altering inputs or have other applications that are running that use specific codes that are detectable because of input alteration or output altering and or filtering or packet sniffing or process monitoring or various other methods to cheat.
Riot has detected A, B, and C about the program
Week 1: Players use the third party software. Get banned
Week 2: Programmer takes out A, still uses B, C, D, E, and F.
Week 3: More players use third party software, get banned.
Week 4: Programmer takes out B. Still uses C, D, E, and F.
Week 5: Players gets banned.
Week 6: Programmer takes out C.
Week 7: Players don't get banned.
Week 8: Programmer now advertises that the program is undetectable with Riot's current measures. Riot now has to invest more money into R&D into detection methods. This means there's going to be a spike in cheating and then a long down time until they discover a new way to detect the third party program. They're now on a huge time crunch to keep up with programmers and it just becomes a race and resources get allocated from things like the player behavior department, map/event content development, hero development, etc... and into anti-cheat detection.
vs
Week 1: Player uses third party software. No bans
Week 2-7: Programmer thinks the program is undetectable. Advertises it like in the first scenario and
Week 8: All the users get banned. Riot doesn't have to spend as much money into R&D for detection methods because the programmers don't know what aspects of their cheating program were detectable. This means they have time and can continue to observe and test the cheating programs that are out there and still have reasonable allocations to the other departments which can generate more income for the company to ultimately help expand the anti-cheat department in the long run.
Ultimately, the cheaters get banned in both scenarios but Riot is indirectly giving away information to the programmers each time they issue bans. Both methods discourage cheating, BUT one is significantly less costly to Riot. It's cost effective for Riot this way.
Cheaters will always make the game miserable for honest players. It happens in all games. It's just a crappy situation.