Check if( selected() )

selected is just an equals if statement that outputs selected or not. It doesn’t perform any special checks, it just makes the code for <option> tags a bit nicer. Without the selected function, you’d need to use a ternary operator, or temporary variables, the code for outputting forms would be awful.

As the official docs say:

Outputs the html selected attribute.

Description

Compares the first two arguments and if identical marks as selected

https://developer.wordpress.org/reference/functions/selected/

So just compare the first two arguments.

What you tried to do here:

} else if( selected( 3, $woocommerce_shop_width, false ) ) {

Is just a very complicated and broken way of doing this:

} else if( 3 == $woocommerce_shop_width ) {