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 (
    1096, 1095, 1097, 1100, 1094, 24018, 
    24127, 1098, 6473, 6486, 6469, 6480, 
    6476, 6470, 40725, 6477, 6482, 6475, 
    6483, 6479, 6484, 6485, 6478, 6472, 
    6474, 6481, 6471
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00516

JSON explain

{
  "query_block": {
    "select_id": 1,
    "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"],
          "rows": 28,
          "filtered": 100,
          "index_condition": "cscart_products_categories.product_id in (1096,1095,1097,1100,1094,24018,24127,1098,6473,6486,6469,6480,6476,6470,40725,6477,6482,6475,6483,6479,6484,6485,6478,6472,6474,6481,6471)"
        }
      },
      {
        "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": ["dev_db.cscart_products_categories.category_id"],
          "rows": 1,
          "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
1094 340M
1095 155M
1096 155M
1097 151M
1098 155M
1100 145M
6469 145M
6470 161M
6471 155M
6472 166M
6473 155M
6474 155M
6475 155M
6476 155M
6477 142M
6478 142M
6479 142M
6480 144M
6481 144M
6482 144M
6483 144M
6484 144M
6485 144M
6486 155M
24018 145M
24127 145M
40725 409,155M