Note, in compounds, Cl2 doesnot mean Cl2 gas(molecule), but it means 2Cl , ie, 2 atoms of Cl. Also, Al2 means 2 atoms of aluminium.
In AlCl3, Al is +3, Cl is -1. So to balance charge, we need 3 Cl . In BaSO4, Ba is +2 and SO4 is +2, so only one each of them are needed for balancing.
In LHS, before reaction, SO4 goes to Al. Al is 3+ and SO4 is -2. So to balance, we need 2 Al and 3 SO4. So we get Al2(SO4)3.
Similarly, Cl goes to Ba, which is +2. So we need 2 cl to balance 1 Ba. So we get BaSO4.
This happens inorder to balance valency (oxidation number) of each element.
But Look!
in LHS, We have 3 BaCl2, ie 3 Ba and 3*2=6 Cl. Also , we have Al2(SO4)3, ie 2 Al and 3 SO4. So finally, it is 3Ba,6Cl,2Al,3SO4
In RHS, we have 3 BaSO4, ie 3 Ba and 3 SO4, Also, in 2AlCl3, we have 2 Al and 3Cl.
Total in RHS = 3Ba,3Cl,2Al,3SO4.
So totally,LHS= RHS