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 (
    1666, 1665, 1663, 1660, 1662, 255, 1661, 
    1658, 1657, 1656, 1655, 1654, 1653, 
    1652, 1651, 1650, 1324, 1647, 1646, 
    1645, 1643, 1642, 1641, 1640
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00112

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": 25,
      "filtered": 100,
      "index_condition": "cscart_products_categories.product_id in (1666,1665,1663,1660,1662,255,1661,1658,1657,1656,1655,1654,1653,1652,1651,1650,1324,1647,1646,1645,1643,1642,1641,1640)"
    },
    "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": ["bacpvdev_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
255 13M
1324 15M
1640 13M
1641 13M
1642 13M
1643 13M
1645 13M
1646 13M
1647 13M
1650 13M
1651 13M
1652 13M
1653 13M
1654 13M
1655 13M
1656 13M
1657 13M
1658 13M
1660 13M
1661 13M
1662 13M
1663 13M
1665 13M
1666 13M