SELECT 
  c.*, 
  IF (c.location_id != 366, 0, 1) as `default` 
FROM 
  cscart_bm_containers as c 
  INNER JOIN cscart_bm_locations as l ON c.location_id = l.location_id 
  AND l.is_default = 1 
  AND l.layout_id = 18 
WHERE 
  1 
  AND c.position IN ('TOP_PANEL', 'HEADER', 'FOOTER') 
  AND c.company_id = 0

Query time 0.00028

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "41.07"
    },
    "nested_loop": [
      {
        "table": {
          "table_name": "l",
          "access_type": "ALL",
          "possible_keys": [
            "PRIMARY"
          ],
          "rows_examined_per_scan": 354,
          "rows_produced_per_join": 3,
          "filtered": "1.00",
          "cost_info": {
            "read_cost": "35.80",
            "eval_cost": "0.35",
            "prefix_cost": "36.15",
            "data_read_per_join": "821"
          },
          "used_columns": [
            "location_id",
            "is_default",
            "layout_id"
          ],
          "attached_condition": "((`shoptheindependents_com`.`l`.`layout_id` = 18) and (`shoptheindependents_com`.`l`.`is_default` = 1))"
        }
      },
      {
        "table": {
          "table_name": "c",
          "access_type": "ref",
          "possible_keys": [
            "location_id",
            "location_id_company_id",
            "location_id_position_company_id"
          ],
          "key": "location_id_company_id",
          "used_key_parts": [
            "location_id",
            "company_id"
          ],
          "key_length": "7",
          "ref": [
            "shoptheindependents_com.l.location_id",
            "const"
          ],
          "rows_examined_per_scan": 3,
          "rows_produced_per_join": 7,
          "filtered": "50.00",
          "cost_info": {
            "read_cost": "3.52",
            "eval_cost": "0.70",
            "prefix_cost": "41.07",
            "data_read_per_join": "2K"
          },
          "used_columns": [
            "container_id",
            "location_id",
            "position",
            "width",
            "user_class",
            "linked_to_default",
            "status",
            "company_id"
          ],
          "attached_condition": "(`shoptheindependents_com`.`c`.`position` in ('TOP_PANEL','HEADER','FOOTER'))"
        }
      }
    ]
  }
}

Result

container_id location_id position width user_class linked_to_default status company_id default
1421 355 TOP_PANEL 16 top-grid Y A 0 0
1422 355 HEADER 16 header-grid Y A 0 0
1424 355 FOOTER 16 ty-footer-grid Y A 0 0