How dynamic action login_form_{action} is working

This is a dynamic hook:

do_action( "login_form_{$action}" );

Meaning that it depends on the $action variable.

There are other such hooks used in the WordPress core.

You can check out the naming convention for dynamic hooks in the Core Contributor Handbook here. It’s says e.g.:

Dynamic hooks should be named using interpolation rather than
concatenation for readability and discoverability purposes.

Double quoted strings in PHP can parse variables, that’s why it’s not written with single quotes:

do_action( 'login_form_{$action}' );

Check out the curly syntax in the PHP docs in the variable parsing section.

Example:

If we have:

$action = 'login';

then it will generate the following action:

do_action( "login_form_login" );

that plugins can hook into via:

add_action( 'login_form_login', ... );