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 (
    2822, 2244, 2245, 2808, 2351, 2352, 2342, 
    2270, 2843, 2225, 2323, 2266, 13822, 
    2813, 2814, 13821, 4378, 2550, 2551, 
    13142, 15143, 15144, 12684, 14457, 
    2176, 2171, 2169, 2168, 2167, 2165
  ) 
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 (2822,2244,2245,2808,2351,2352,2342,2270,2843,2225,2323,2266,13822,2813,2814,13821,4378,2550,2551,13142,15143,15144,12684,14457,2176,2171,2169,2168,2167,2165)"
    },
    "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
2165 357M
2167 357M
2168 357M
2169 357M
2171 357M
2176 357M
2225 357M
2244 357M
2245 357M
2266 357M
2270 357M
2323 357M
2342 357M
2351 357M
2352 357M
2550 356M
2551 356M
2808 356M
2813 356M
2814 356M
2822 356M
2843 356M
4378 355M
12684 356M
13142 265M
13821 355,265M
13822 355,392,265M
14457 383,265M
15143 356,357,265M
15144 356,357,265M