Why are all block images updating when selecting a single collection?

Hi all, I have a problem.

Basically I have blocks with background images and titles set based on the collection chosen.

When I select a collection in the 1st block, the title works fine (The title changes for only the 1st block) however the background images update for ALL blocks.

Here’s a photo of the problem happening:

Here’s the code:

{% for block in section.blocks %}

    {% assign collection = collections[block.settings.collection] %}

    {% if collection == blank %}
    {% assign collection_title = 'Collection Title Here' %}
    {% elsif collection != blank and block.settings.title == blank %}
    {% assign collection_title = collection.title %}
    {% elsif collection != blank and block.settings.title != blank %}
    {% assign collection_title = block.settings.title %}
    {% endif %}

    {% if collection != blank and block.settings.image == blank %}
    {% assign background_image = collection.image %}
    {% elsif collection != blank and block.settings.image != blank %}
    {% assign background_image = block.settings.image %}
    {% endif %}

    
      
        

          ## {{ collection_title }}
          

{{
            block.settings.one_line_collection_description }}

        

      
    

    {% endfor %}

Where did I go wrong? Why is it duplicating?

Follow-up question: what does this mean exactly? What does the bracket mean?

{% assign collection = collections[block.settings.collection] %}