Can’t make wp_enqueue work

Edit: I meant to refer to wp_dequeue_style()

You have to dequeque (unregister) the scripts or styles that you wish to replace before replacing them or the new parameters won’t be accepted. Use wp_dequeue_style(). Also, as it says in the description for wp_dequeue_script(), hook it with a late priority (100), so that it is after the script was enqueued.

I believe your function my_enqueue_styles() is where you would want to make use of wp_dequeue_style() just before wp_enqueue_style() is used. Something like this:

function my_enqueue_styles() {
    if ( is_front_page() ) {
        wp_dequeue_style( 'style1' );
        wp_enqueue_style( 'style1' );
    } else {
        wp_dequeue_style( 'style1' );
        wp_enqueue_style( 'style2' );
    }
}

Then add the integer 100 as an argument in your action hook.
add_action( 'wp_enqueue_scripts', 'my_enqueue_styles', 100 );

Deque any other scripts or styles you wish to enqueue that have already been enqueued.

tech