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 (
    19938, 19939, 19940, 19941, 19943, 19600, 
    19601, 18570, 14106, 14070, 14045, 
    14051, 14044, 14097, 14093, 14105, 
    14125, 18488, 18489, 18600, 18603
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00051

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost": 0.058361468,
    "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": 21,
          "cost": 0.022871025,
          "filtered": 100,
          "attached_condition": "cscart_products_categories.product_id in (19938,19939,19940,19941,19943,19600,19601,18570,14106,14070,14045,14051,14044,14097,14093,14105,14125,18488,18489,18600,18603)",
          "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": ["u508912950_dev_2025.cscart_products_categories.category_id"],
          "loops": 21,
          "rows": 1,
          "cost": 0.02206004,
          "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
14044 644M
14045 644M
14051 644M
14070 644M
14093 644M
14097 644M
14105 644M
14106 644M
14125 644M
18488 309M
18489 309M
18570 1716M
18600 309M
18603 309M
19600 1206M
19601 1206M
19938 484M
19939 484M
19940 484M
19941 484M
19943 1617M