wp_nav_menu not selecting teh correct menu

I faced the same issue and finally got the answer:

For functions.php:

register_nav_menu( 'primary', __( 'Navigation Menu', 'Removemymug_Theme' ) );
register_nav_menu( 'second-menu', __( 'Second Menu', 'Removemymug_Theme' ) );

For Secondary Menu (Footer):

wp_nav_menu( array(
    'menu'            => 'second-menu',
    'theme_location'  => 'second-menu',
    'depth'           => 2,
    'container'       => 'div',
    'container_class' => 'navbar-collapse collapse',
    'menu_class'      => 'nav navbar-nav navbar-right',
    'fallback_cb'     => 'wp_bootstrap_navwalker::fallback',
    'walker'          => new wp_bootstrap_navwalker()
) );

For Top Navigation:

wp_nav_menu( array(
    'menu'            => 'primary',
    'theme_location'  => 'primary',
    'depth'           => 2,
    'container'       => 'div',
    'container_class' => 'navbar-collapse collapse',
    'menu_class'      => 'nav navbar-nav navbar-right',
    'fallback_cb'     => 'wp_bootstrap_navwalker::fallback',
    'walker'          => new wp_bootstrap_navwalker()
) );