When we use VRRP and MSTP must ensure that VRRP's Master and Backup overlap with the main and backup root of MSTP.
That is to say, SW1 is MSTP primary root of instance 1, which is also the VRRP Master of vlanif A and vlanif B,
SW2 is the primary root of MSTP instance 2, and it is VRRP Master of vlanif A and vlanif B.