First of all, there are three steps in the fight phase, fight first, fight normally, fight last.
Unit A1 fights first, because it charged. Then unit B1 fights. Charging units are treated as fight first units. And if two or more units fight first, the players whose turn it is goes first, then the other player fights with a fight first unit, then the other, and so on, until all fight first units have fought.
Now, we move on to units who fight normally. Which are units which already are in engagement range, and didnt charge. Or units which have a fight first, and fight last rule at the same time. Here, the player whose turn is not taking place fights first. In this case it would be unit B2, after that its unit A2. If unit B2 kills models from unit A2, and that unit is no longer in coherency, it must restore coherency when it moves (pile in, consolidate), if thats not possible the unit cant move. The coherency check where you remove models which arent in coherency is done in the morale phase.
Finally, in the fight phase, units who fight last would fight after all units who fought normally.
Here is a pdf explaining the fight phase.
https://www.warhammer-community.com/wp-content/uploads/2020/08/OQ1TeUZ6hxw5jp1e.pdf