SELECT 
  c.service_type_id, 
  COUNT(DISTINCT pc.product_id) AS count 
FROM 
  cscart_categories AS c 
  INNER JOIN cscart_products_categories AS pc ON pc.category_id = c.category_id 
WHERE 
  c.service_type_id IN (2, 3, 1, 5, 6, 7, 8, 9) 
GROUP BY 
  c.service_type_id

Query time 0.00837

JSON explain

{
  "query_block": {
    "select_id": 1,
    "read_sorted_file": {
      "filesort": {
        "sort_key": "c.service_type_id",
        "table": {
          "table_name": "c",
          "access_type": "ALL",
          "possible_keys": ["PRIMARY", "p_category_id"],
          "rows": 142,
          "filtered": 100,
          "attached_condition": "c.service_type_id in (2,3,1,5,6,7,8,9)"
        }
      }
    },
    "table": {
      "table_name": "pc",
      "access_type": "ref",
      "possible_keys": ["PRIMARY"],
      "key": "PRIMARY",
      "key_length": "3",
      "used_key_parts": ["category_id"],
      "ref": ["dev.c.category_id"],
      "rows": 29,
      "filtered": 100,
      "using_index": true
    }
  }
}

Result

service_type_id count
1 18
2 2636
3 49
5 3
7 1
9 5