You could use the wp_insert_comment action to detect when new comments are added to a post. Then on your action callback, you’d the post’s comment count with get_comments_number(), and change post categories with wp_set_object_terms().
Something along these lines,
add_filter(
'wp_insert_comment',
function($id, $comment) {
if ( (int) $comment->comment_approved ) {
$post_id = (int) $comment->comment_post_ID;
$post_comment_count = get_comments_number(
$post_id
);
if ( $post_comment_count > 3 ) {
wp_set_object_terms(
$post_id,
array('3-comments'),
'category',
false // don't append, overwrite terms
);
} else if ( $post_comment_count === 2 ) {
wp_set_object_terms(
$post_id,
array('2-comments'),
'category',
false // don't append, overwrite terms
);
} else {
wp_set_object_terms(
$post_id,
array('1-comment'),
'category',
false // don't append, overwrite terms
);
}
}
},
10,
2
);