Why did Erica Sloane turn out the lights near the end of Mission: Impossible - Fallout that allowed August Walker to have his team fire on the CIA agents? What was her purpose? I was very confused with this action.
Erica Sloan did not intend for Walker/Lark to take out Ethan's team and escape. It wasn't his team rather than her's/the CIA's. She didn't actually know that Walker/Lark had men amongst her team. Granted, it's not entirely clear how Lark managed to do this, but also not impossible for him to have his own men inside the CIA or just replacing Sloan's extraction team beforehand. He's just prepared for many situations and always quite ahead of the others and we have to accept that he orchestrated this somehow. However, Sloan wasn't aware of that and she was tricked by him as much as anyone else.
But why did she turn out the lights then and send in a team? Well, it's also emphasised repeatedly that Erica Sloan, and the CIA she represents, prefer the brute-force method over the intricate technological coups that the IMF tends to do. This is shown when she criticizes Hunt for putting his team above the mission or when Walker ridicules them for their gadgets. She likes to kill or capture the bad guys rather than playing with them. (And she only realizes the importance of Hunt's and the IMF's way at the end of the film.)
So what she does here is her protocol for resolving the weird situation they're in: shut everything down and apprehend everyone, then get some answers at home! Yes, Hunley might have vouched for Hunt and the team might have uncovered Walker to be Lark under Sloan's supervision. But...she still doesn't trust anyone of these people all too far, and particularly not Hunt to bring back the plutonium safely. So she uses the big hammer to clear this mess up right now and worry about the plutonium later/separately. What she didn't expect was for Walker/Lark to be onto it and use her lockdown to his advantage. And you could even take that failure as another sign for the problems her stubbornness causes.