SELECT 
  cscart_products_categories.product_id, 
  GROUP_CONCAT(
    IF(
      cscart_products_categories.link_type = "M", 
      CONCAT(
        cscart_products_categories.category_id, 
        "M"
      ), 
      cscart_products_categories.category_id
    )
  ) AS category_ids 
FROM 
  cscart_products_categories 
  INNER JOIN cscart_categories ON cscart_categories.category_id = cscart_products_categories.category_id 
  AND cscart_categories.storefront_id IN (0, 1) 
  AND cscart_categories.status IN ('A', 'H') 
WHERE 
  cscart_products_categories.product_id IN (
    66159, 65388, 65403, 65404, 65406, 65407, 
    65409, 65411, 65412, 65413, 65414, 
    65415, 65417, 65433, 65464, 66147, 
    66162, 66183, 66186, 64396, 65422, 
    65423, 65426, 65427
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00140

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "24.00"
    },
    "grouping_operation": {
      "using_filesort": false,
      "nested_loop": [
        {
          "table": {
            "table_name": "cscart_products_categories",
            "access_type": "range",
            "possible_keys": [
              "PRIMARY",
              "link_type",
              "pt",
              "idx_product_category_lookup",
              "idx_products_categories_composite"
            ],
            "key": "idx_products_categories_composite",
            "used_key_parts": [
              "product_id"
            ],
            "key_length": "3",
            "rows_examined_per_scan": 43,
            "rows_produced_per_join": 43,
            "filtered": "100.00",
            "using_index": true,
            "cost_info": {
              "read_cost": "4.65",
              "eval_cost": "4.30",
              "prefix_cost": "8.95",
              "data_read_per_join": "688"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "link_type"
            ],
            "attached_condition": "(`cscart_db`.`cscart_products_categories`.`product_id` in (66159,65388,65403,65404,65406,65407,65409,65411,65412,65413,65414,65415,65417,65433,65464,66147,66162,66183,66186,64396,65422,65423,65426,65427))"
          }
        },
        {
          "table": {
            "table_name": "cscart_categories",
            "access_type": "eq_ref",
            "possible_keys": [
              "PRIMARY",
              "p_category_id",
              "idx_categories_storefront_status",
              "idx_categories_usergroup_status",
              "idx_categories_status_id_path"
            ],
            "key": "PRIMARY",
            "used_key_parts": [
              "category_id"
            ],
            "key_length": "3",
            "ref": [
              "cscart_db.cscart_products_categories.category_id"
            ],
            "rows_examined_per_scan": 1,
            "rows_produced_per_join": 35,
            "filtered": "81.96",
            "cost_info": {
              "read_cost": "10.75",
              "eval_cost": "3.52",
              "prefix_cost": "24.00",
              "data_read_per_join": "98K"
            },
            "used_columns": [
              "category_id",
              "status",
              "storefront_id"
            ],
            "attached_condition": "((`cscart_db`.`cscart_categories`.`storefront_id` in (0,1)) and (`cscart_db`.`cscart_categories`.`status` in ('A','H')))"
          }
        }
      ]
    }
  }
}

Result

product_id category_ids
64396 2517M,2518
65388 2505M,2510
65403 2505M,2506
65404 2505M,2506
65406 2505M,2506
65407 2505M,2506
65409 2505M,2506
65411 2505M,2510
65412 2505M,2510
65413 2505M,2510
65414 2505M,2510
65415 2505M,2510
65417 2505M,2510
65422 2510,2523M
65423 2510,2523M
65426 2510,2523M
65427 2510,2523M
65433 2510,2523M
65464 2510,2517M
66147 2505M
66159 2521M
66162 2521M
66183 2512M
66186 2526M