Please try to use this function
https://codex.wordpress.org/Function_Reference/wp_dropdown_categories
wp_dropdown_categories() – Display the HTML dropdown list of categories
<form id="category-select" class="category-select" action="<?php echo esc_url( home_url( "https://wordpress.stackexchange.com/" ) ); ?>" method="get">
<?php wp_dropdown_categories(); ?>
<input type="submit" name="submit" value="view" />
</form>