It takes time to recycle the debris, and moon formation is determined at the end of the battle. In this case, it looks like the fight lasted for 10 minutes and produced a total of 13M metal + 8M mineral.
At the end of the battle (10 minutes), your providers had collected about 6M metal and about 5M minerals, leaving roughly 7M metal and 3M mineral....however, that still left enough to form a moon when the battle ended, and it seems that is exactly what happened.
In order to prevent a moon from forming, there must not be enough debris when the fight actually ends...either more providers, higher recycling speed, or extend the fight to allow providers to collect more debris would have been options to prevent moon formation