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 (
    65396, 66114, 66115, 65399, 66116, 65457, 
    66157, 65395, 65459, 66131, 66161, 
    66132, 66160, 66104, 66105, 66111, 
    66990, 65482, 66167, 66101, 65387, 
    65410, 65418, 66136
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00101

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "18.06"
    },
    "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": 32,
            "rows_produced_per_join": 32,
            "filtered": "100.00",
            "using_index": true,
            "cost_info": {
              "read_cost": "3.66",
              "eval_cost": "3.20",
              "prefix_cost": "6.86",
              "data_read_per_join": "512"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "link_type"
            ],
            "attached_condition": "(`cscart_db`.`cscart_products_categories`.`product_id` in (65396,66114,66115,65399,66116,65457,66157,65395,65459,66131,66161,66132,66160,66104,66105,66111,66990,65482,66167,66101,65387,65410,65418,66136))"
          }
        },
        {
          "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": 26,
            "filtered": "81.96",
            "cost_info": {
              "read_cost": "8.00",
              "eval_cost": "2.62",
              "prefix_cost": "18.06",
              "data_read_per_join": "73K"
            },
            "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
65387 2505M,2510
65395 2505M,2521
65396 2505M,2521
65399 2505M,2521
65410 2505M,2510
65418 2505M,2510
65457 2525M,2526
65459 2517M,2518
65482 2530M
66101 2516M
66104 2521M
66105 2521M
66111 2521M
66114 2521M
66115 2521M
66116 2521M
66131 2521M
66132 2521M
66136 2521M
66157 2521M
66160 2521M
66161 2521M
66167 2521M
66990 2521M