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 (
    12669, 12975, 2299, 2297, 2298, 2203, 
    2566, 3215, 3214, 11118, 12685, 13990, 
    2340, 11888, 2339, 2338, 2180, 2181, 
    13661, 15141, 2228, 2226, 2227, 2336, 
    12743, 2185, 14298, 15154, 13222, 15155
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00052

JSON explain

{
  "query_block": {
    "select_id": 1,
    "table": {
      "table_name": "cscart_products_categories",
      "access_type": "range",
      "possible_keys": ["PRIMARY", "pt"],
      "key": "pt",
      "key_length": "3",
      "used_key_parts": ["product_id"],
      "rows": 40,
      "filtered": 100,
      "index_condition": "cscart_products_categories.product_id in (12669,12975,2299,2297,2298,2203,2566,3215,3214,11118,12685,13990,2340,11888,2339,2338,2180,2181,13661,15141,2228,2226,2227,2336,12743,2185,14298,15154,13222,15155)"
    },
    "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": ["ymonline_livedata.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
2180 357M
2181 357M
2185 357M
2203 357M
2226 357M
2227 357M
2228 357M
2297 357M
2298 357M
2299 357M
2336 357M
2338 357M
2339 357M
2340 357M
2566 356M
3214 356M
3215 356M
11118 356M
11888 357M
12669 392M
12685 356M
12743 357M
12975 357,356M
13222 356,265M
13661 357M
13990 357,265M
14298 356,265M
15141 357,265M
15154 356,265M
15155 356,265M