Barrier vehicles are used to provide braking effort when a carriage/carriages/multiple unit etc is being moved by a loco and it isn't possible to convert (or "translate") the loco's pneumatic brake control system into the towed vehicles brake control system - either because they aren't compatible, translator vehicles available/applicable or the towed vehicle's brakes aren't working.
The vehicles being towed are unbraked, known as "swingers".
The loco can brake the barrier vehicles - so the loco is coupled, mechanically and air, as normal to the 1st rake of barrier vehicles. the 1st rake is then coupled mechanically to the towed vehicles and an air pipe for the brakes is run through the towed vehicles to 2nd rake of barrier vehicles coupled on the back of the towed vehicles. The air pipe connects to the 2nd rake's brakes. When the driver applies the brakes in the loco cab this means the loco's brakes, the 1st rake's brakes and the 2nd rake's brakes all apply in a controlled manner.
The sheer number of barrier vehicles in the 1st and 2nd rake is to provide the extra brake effort needed to slow the consist with the swingers in the middle and to ensure that if there is a break away between any of the vehicles in the consist, which will destroy the integrity of the pneumatic supply through the consist and cause all of the brakes to come on, there is always enough brake effort to bring the respective parts of the train to a stop as quickly as possible.