How do I stop the loop from repeating in my category template?

You have three loops, two nested inside the main loop. The main loop display the posts e.g. in category_a. What does the second nested loop display? It seems this loops also display the posts from the samne category as the main loop. So try to remove the second nested loop.