How to get the post type from a category id?

You can just grab the first post from the main query and see which post type it is:

if ( have_posts() ) {
    $post_type = $wp_query->posts[0]->post_type;
}

If you run this code directly in a main template file you should be fine, but if it’s in a function you will need to call global $wp_query; first.