How to pass menu slug as a variable to wp_nav_menu?

You want get_field() (which returns the value), not the_field() (which echo’s the value):

$var = get_field( 'menu2' );