SELECT 
  products_categories.product_id, 
  GROUP_CONCAT(
    IF(
      products_categories.link_type = "M", 
      CONCAT(
        products_categories.category_id, 
        "M"
      ), 
      products_categories.category_id
    )
  ) AS category_ids, 
  product_position_source.position AS position 
FROM 
  products_categories 
  INNER JOIN categories ON categories.category_id = products_categories.category_id 
  AND categories.storefront_id IN (0, 1) 
  AND (
    categories.usergroup_ids = '' 
    OR FIND_IN_SET(0, categories.usergroup_ids) 
    OR FIND_IN_SET(1, categories.usergroup_ids)
  ) 
  AND categories.status IN ('A', 'H') 
  LEFT JOIN products_categories AS product_position_source ON products_categories.product_id = product_position_source.product_id 
  AND product_position_source.category_id = 4827 
WHERE 
  products_categories.product_id IN (
    96195, 96943, 96192, 97011, 96985, 97018, 
    97022, 97023, 96930, 96926, 97021, 
    96996, 96194, 96931, 97013, 96994, 
    96216, 97031, 97041, 97042, 97006, 
    96960, 96976, 96956
  ) 
GROUP BY 
  products_categories.product_id

Query time 0.00216

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "85.80"
    },
    "grouping_operation": {
      "using_filesort": false,
      "nested_loop": [
        {
          "table": {
            "table_name": "products_categories",
            "access_type": "range",
            "possible_keys": [
              "PRIMARY",
              "link_type",
              "pt"
            ],
            "key": "pt",
            "used_key_parts": [
              "product_id"
            ],
            "key_length": "3",
            "rows_examined_per_scan": 95,
            "rows_produced_per_join": 95,
            "filtered": "100.00",
            "using_index": true,
            "cost_info": {
              "read_cost": "9.80",
              "eval_cost": "9.50",
              "prefix_cost": "19.30",
              "data_read_per_join": "1K"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "link_type"
            ],
            "attached_condition": "(`goimagine`.`products_categories`.`product_id` in (96195,96943,96192,97011,96985,97018,97022,97023,96930,96926,97021,96996,96194,96931,97013,96994,96216,97031,97041,97042,97006,96960,96976,96956))"
          }
        },
        {
          "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",
              "goimagine.products_categories.product_id"
            ],
            "rows_examined_per_scan": 1,
            "rows_produced_per_join": 95,
            "filtered": "100.00",
            "cost_info": {
              "read_cost": "23.75",
              "eval_cost": "9.50",
              "prefix_cost": "52.55",
              "data_read_per_join": "1K"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "position"
            ]
          }
        },
        {
          "table": {
            "table_name": "categories",
            "access_type": "eq_ref",
            "possible_keys": [
              "PRIMARY",
              "c_status",
              "p_category_id"
            ],
            "key": "PRIMARY",
            "used_key_parts": [
              "category_id"
            ],
            "key_length": "3",
            "ref": [
              "goimagine.products_categories.category_id"
            ],
            "rows_examined_per_scan": 1,
            "rows_produced_per_join": 4,
            "filtered": "5.00",
            "cost_info": {
              "read_cost": "23.75",
              "eval_cost": "0.48",
              "prefix_cost": "85.80",
              "data_read_per_join": "12K"
            },
            "used_columns": [
              "category_id",
              "usergroup_ids",
              "status",
              "storefront_id"
            ],
            "attached_condition": "((`goimagine`.`categories`.`storefront_id` in (0,1)) and ((`goimagine`.`categories`.`usergroup_ids` = '') or (0 <> find_in_set(0,`goimagine`.`categories`.`usergroup_ids`)) or (0 <> find_in_set(1,`goimagine`.`categories`.`usergroup_ids`))) and (`goimagine`.`categories`.`status` in ('A','H')))"
          }
        }
      ]
    }
  }
}

Result

product_id category_ids position
96192 109,4827,4838,4M 0
96194 5,4827,4834,4M 0
96195 5,4827,4834,4M 0
96216 23,4827,4834,4M 0
96926 114,4827,33M 0
96930 111,4827,4843,33M 0
96931 38,4827,4840,33M 0
96943 33,4827,4833,26M 0
96956 33,4827,4841,26M 0
96960 121,4827,4840,33M 0
96976 238,4827,4844,118M 0
96985 238,4827,4840,121M 0
96994 238,4827,4833,192M 0
96996 238,4827,4839,116M 0
97006 238,4827,4839,33M 0
97011 259,4827,4834,238M 0
97013 266,4827,4832,238M 0
97018 238,4827,4843,111M 0
97021 238,4827,4837,236M 0
97022 238,4827,4838,236M 0
97023 238,4827,4833,191M 0
97031 238,4827,4833,183M 0
97041 238,4827,4837,236M 0
97042 183,4827,4838,238M 0