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 (
    65428, 65429, 65430, 65431, 65432, 65434, 
    65435, 65436, 65438, 65439, 65440, 
    65441, 65442, 65443, 65444, 65445, 
    65446, 65447, 65448, 65449, 65450, 
    65451, 65452, 65454
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00114

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "26.77"
    },
    "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": 48,
            "rows_produced_per_join": 48,
            "filtered": "100.00",
            "using_index": true,
            "cost_info": {
              "read_cost": "5.17",
              "eval_cost": "4.80",
              "prefix_cost": "9.97",
              "data_read_per_join": "768"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "link_type"
            ],
            "attached_condition": "(`cscart_db`.`cscart_products_categories`.`product_id` in (65428,65429,65430,65431,65432,65434,65435,65436,65438,65439,65440,65441,65442,65443,65444,65445,65446,65447,65448,65449,65450,65451,65452,65454))"
          }
        },
        {
          "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": 39,
            "filtered": "81.96",
            "cost_info": {
              "read_cost": "12.00",
              "eval_cost": "3.93",
              "prefix_cost": "26.77",
              "data_read_per_join": "110K"
            },
            "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
65428 2506,2523M
65429 2506,2523M
65430 2506,2523M
65431 2506,2523M
65432 2506,2523M
65434 2510,2523M
65435 2510,2523M
65436 2510,2523M
65438 2510,2523M
65439 2510,2523M
65440 2510,2523M
65441 2510,2523M
65442 2510,2523M
65443 2510,2523M
65444 2510,2523M
65445 2510,2523M
65446 2510,2523M
65447 2510,2523M
65448 2510,2523M
65449 2510,2523M
65450 2510,2523M
65451 2510,2523M
65452 2510,2523M
65454 2510,2523M