The conjugated dienes add the acids of the halogens forming kinetic and thermodynamic products, whose ratio can be controlled with the reaction conditions (temperature and time).
Mechanism:
Stage 1. Electrophilic addition with formation of allylic carbocation
Stage 2. Nucleophilic attack of the bromide.