Conditional statment for customer and vendor tag

I’m confused why my conditional statement on cart page works written one way vs the other. Looking for an explanation or a solution.

1. If the account had tag1, it would show the condition. But if the account had tag2 it wouldn’t output the condition statement

{% if customer.tags contains “tag1” and line_item.vendor == “vendor1”
or customer.tags contains “tag2” and line_item.vendor == “vendor1” %}

{% elsif customer.tags contains “tag1” and line_item.vendor == “vendor2” or customer.tags contains “tag2” and line_item.vendor == “vendor2” %}

2. However, if I write it this way, it works.

{% if line_item.vendor == “vendor1” and customer.tags contains “tag1” or line_item.vendor == “vendor1” and customer.tags contains “tag2” and line_item.vendor == “vendor1” %}