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.usergroup_ids = '' 
    OR FIND_IN_SET(
      0, cscart_categories.usergroup_ids
    ) 
    OR FIND_IN_SET(
      1, cscart_categories.usergroup_ids
    )
  ) 
  AND cscart_categories.status IN ('A', 'H') 
WHERE 
  cscart_products_categories.product_id IN (
    400987, 426059, 409013, 444321, 439971, 
    404749, 408586, 442172, 413163, 435730, 
    415231, 453032, 414229, 408226, 430218, 
    429505, 404254, 447216, 440066, 418544, 
    413112, 404724, 427182, 430037
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00055

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost": 0.081460403,
    "nested_loop": [
      {
        "table": {
          "table_name": "cscart_products_categories",
          "access_type": "range",
          "possible_keys": ["PRIMARY", "pt"],
          "key": "pt",
          "key_length": "3",
          "used_key_parts": ["product_id"],
          "loops": 1,
          "rows": 24,
          "cost": 0.04381364,
          "filtered": 100,
          "attached_condition": "cscart_products_categories.product_id in (400987,426059,409013,444321,439971,404749,408586,442172,413163,435730,415231,453032,414229,408226,430218,429505,404254,447216,440066,418544,413112,404724,427182,430037)",
          "using_index": true
        }
      },
      {
        "table": {
          "table_name": "cscart_categories",
          "access_type": "eq_ref",
          "possible_keys": ["PRIMARY", "c_status", "p_category_id"],
          "key": "PRIMARY",
          "key_length": "3",
          "used_key_parts": ["category_id"],
          "ref": ["u985510652_ecartify.cscart_products_categories.category_id"],
          "loops": 24,
          "rows": 1,
          "cost": 0.02228576,
          "filtered": 100,
          "attached_condition": "cscart_categories.storefront_id in (0,1) and (cscart_categories.usergroup_ids = '' or find_in_set(0,cscart_categories.usergroup_ids) or find_in_set(1,cscart_categories.usergroup_ids)) and cscart_categories.`status` in ('A','H')"
        }
      }
    ]
  }
}

Result

product_id category_ids
400987 495M
404254 305M
404724 305M
404749 495M
408226 498M
408586 305M
409013 305M
413112 498M
413163 305M
414229 498M
415231 305M
418544 495M
426059 305M
427182 500M
429505 305M
430037 500M
430218 498M
435730 495M
439971 498M
440066 289M
442172 495M
444321 289M
447216 289M
453032 500M