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 = 1 
WHERE 
  cscart_products_categories.product_id IN (
    13878, 13877, 13876, 13875, 13874, 13873, 
    13872, 13870, 13869, 13829, 13862, 
    13858, 13850, 13849, 13848, 13847, 
    13846, 13845, 13844, 13843, 13842, 
    13841, 13840, 13839, 13838, 13837, 
    13836, 13835, 13834, 13833, 13832, 
    13831, 13830, 13827, 13826, 13825, 
    13824, 13823, 13822, 13821
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00067

Explain
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE cscart_products_categories range PRIMARY,pt pt 3 40 Using where; Using index
1 SIMPLE cscart_categories eq_ref PRIMARY,c_status,p_category_id PRIMARY 3 toolboxdigitalshop_dev.cscart_products_categories.category_id 1 Using where
1 SIMPLE product_position_source eq_ref PRIMARY,pt PRIMARY 6 const,toolboxdigitalshop_dev.cscart_products_categories.product_id 1

Result

product_id category_ids position
13821 1M 0
13822 1M 0
13823 1M 0
13824 1M 0
13825 1M 0
13826 1M 0
13827 1M 0
13829 1M 0
13830 1M 0
13831 1M 0
13832 1M 0
13833 1M 0
13834 1M 0
13835 1M 0
13836 1M 0
13837 1M 0
13838 1M 0
13839 1M 0
13840 1M 0
13841 1M 0
13842 1M 0
13843 1M 0
13844 1M 0
13845 1M 0
13846 1M 0
13847 1M 0
13848 1M 0
13849 1M 0
13850 1M 0
13858 1M 0
13862 1M 0
13869 1M 0
13870 1M 0
13872 1M 0
13873 1M 0
13874 1M 0
13875 1M 0
13876 1M 0
13877 1M 0
13878 1M 0