shear walls prevent swaying of the structure when there is a lateral load to the building such as wind or earthquake. the walls are placed in both perpendicular directions so that the lateral load from any direction can be countered.

if you do not have shear walls, you can make diagonal braces if it is a steel building, or, you can make your concrete building moment frame strong enough (at the beam column connections) to counter these forces, but generally shear walls inherently are much more effective due to its geometry.

one thing to keep in mind is, when you place shear walls you do not want that your building will be in torsion when there is a lateral load, so you must place the shear walls such that their geometrical center will be the same or not far from the geometrical center of your building floor plan.