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, 
  product_position_source.position AS position 
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') 
  LEFT JOIN cscart_products_categories AS product_position_source ON cscart_products_categories.product_id = product_position_source.product_id 
  AND product_position_source.category_id = 553 
WHERE 
  cscart_products_categories.product_id IN (
    5290, 5271, 4974, 5277, 5640, 5284, 5376, 
    5287, 5281, 5397, 4995, 5270, 5278, 
    5187, 5549, 4992, 5207, 5186, 5008, 
    5272, 4991, 5276, 5285, 5346
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00256

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "170.46"
    },
    "grouping_operation": {
      "using_filesort": false,
      "nested_loop": [
        {
          "table": {
            "table_name": "cscart_products_categories",
            "access_type": "range",
            "possible_keys": [
              "PRIMARY",
              "pt"
            ],
            "key": "pt",
            "used_key_parts": [
              "product_id"
            ],
            "key_length": "3",
            "rows_examined_per_scan": 143,
            "rows_produced_per_join": 143,
            "filtered": "100.00",
            "index_condition": "(`softwarepirmam_hewadelivard_cscart_4`.`cscart_products_categories`.`product_id` in (5290,5271,4974,5277,5640,5284,5376,5287,5281,5397,4995,5270,5278,5187,5549,4992,5207,5186,5008,5272,4991,5276,5285,5346))",
            "cost_info": {
              "read_cost": "56.06",
              "eval_cost": "14.30",
              "prefix_cost": "70.36",
              "data_read_per_join": "2K"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "link_type"
            ]
          }
        },
        {
          "table": {
            "table_name": "product_position_source",
            "access_type": "eq_ref",
            "possible_keys": [
              "PRIMARY",
              "pt"
            ],
            "key": "PRIMARY",
            "used_key_parts": [
              "category_id",
              "product_id"
            ],
            "key_length": "6",
            "ref": [
              "const",
              "softwarepirmam_hewadelivard_cscart_4.cscart_products_categories.product_id"
            ],
            "rows_examined_per_scan": 1,
            "rows_produced_per_join": 143,
            "filtered": "100.00",
            "cost_info": {
              "read_cost": "35.75",
              "eval_cost": "14.30",
              "prefix_cost": "120.41",
              "data_read_per_join": "2K"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "position"
            ]
          }
        },
        {
          "table": {
            "table_name": "cscart_categories",
            "access_type": "eq_ref",
            "possible_keys": [
              "PRIMARY",
              "c_status",
              "p_category_id"
            ],
            "key": "PRIMARY",
            "used_key_parts": [
              "category_id"
            ],
            "key_length": "3",
            "ref": [
              "softwarepirmam_hewadelivard_cscart_4.cscart_products_categories.category_id"
            ],
            "rows_examined_per_scan": 1,
            "rows_produced_per_join": 7,
            "filtered": "5.00",
            "cost_info": {
              "read_cost": "35.75",
              "eval_cost": "0.72",
              "prefix_cost": "170.46",
              "data_read_per_join": "22K"
            },
            "used_columns": [
              "category_id",
              "storefront_id",
              "usergroup_ids",
              "status"
            ],
            "attached_condition": "((`softwarepirmam_hewadelivard_cscart_4`.`cscart_categories`.`storefront_id` in (0,1)) and ((`softwarepirmam_hewadelivard_cscart_4`.`cscart_categories`.`usergroup_ids` = '') or (0 <> find_in_set(0,`softwarepirmam_hewadelivard_cscart_4`.`cscart_categories`.`usergroup_ids`)) or (0 <> find_in_set(1,`softwarepirmam_hewadelivard_cscart_4`.`cscart_categories`.`usergroup_ids`))) and (`softwarepirmam_hewadelivard_cscart_4`.`cscart_categories`.`status` in ('A','H')))"
          }
        }
      ]
    }
  }
}

Result

product_id category_ids position
4974 372,552,556,553,250,554M 0
4991 552,554,553,372,250,556M 0
4992 552,553,554,250,372,556M 0
4995 552,553,554,372,250,556M 0
5008 561,555,557,552,553,372,250,563M 0
5186 372,250,557,555,562,553,552,560M 0
5187 557,555,250,372,562,553,552,560M 0
5207 372,250,555,557,552,553,563,561M 0
5270 250,372,563,557,555,553,552,561M 0
5271 250,372,563,557,555,553,552,561M 0
5272 250,372,563,557,555,553,552,561M 0
5276 250,372,563,557,555,553,552,561M 0
5277 250,372,563,557,555,553,552,561M 0
5278 250,372,563,557,555,553,552,561M 0
5281 250,372,563,557,555,553,552,561M 0
5284 400,372,563,557,555,553,552,561M 0
5285 250,372,563,557,555,553,552,561M 0
5287 372,250,563,557,555,553,552,561M 0
5290 250,372,563,557,555,553,552,561M 0
5346 554,553,250,372,552,556M 0
5376 372,250,553,552,554,556M 0
5397 372,250,553,554,552,556M 0
5549 553,250,552,554,372,556M 0
5640 555,553,250,560,557,552,372,562M 0