How to know a backup command failed or worked in a script
the problem is the error severity of the backup exception.
I simulated your situation with this script:
BACKUP DATABASE [test] TO  DISK = N'X:\DB\SQL\2019\MSSQL15.MSSQLSERVER\MSSQL\Backup\test.bak' 
WITH NOFORMAT, NOINIT,  NAME = N'test-Full Database Backup', SKIP, NOREWIND, NOUNLOAD,  STATS = 10

BACKUP DATABASE [test] TO  DISK = N'C:\DB\SQL\2019\MSSQL15.MSSQLSERVER\MSSQL\Backup\test.bak' 
WITH NOFORMAT, NOINIT,  NAME = N'test-Full Database Backup', SKIP, NOREWIND, NOUNLOAD,  STATS = 10

The first command generate an error of severity 16 (path not found)
Msg 3201, Level 16, State 1, Line 1
Cannot open backup device 'X:\DB\SQL\2019\MSSQL15.MSSQLSERVER\MSSQL\Backup\test.bak'. Operating system error 3(path not found.).
Msg 3013, Level 16, State 1, Line 1
BACKUP DATABASE is terminating abnormally.
and then sql server continues to execute the next command:
11 percent processed.
21 percent processed.
30 percent processed.
40 percent processed.
50 percent processed.
61 percent processed.
71 percent processed.
80 percent processed.
90 percent processed.
100 percent processed.
Processed 504 pages for database 'test', file 'test' on file 2.
Processed 2 pages for database 'test', file 'test_log' on file 2.
BACKUP DATABASE successfully processed 506 pages in 0.029 seconds (136.179 MB/sec).
Completion time: 2021-01-07T14:06:19.6844320+01:00
As you can see here:
https://docs.microsoft.com/en-us/sql/relational-databases/errors-events/database-engine-error-severities?view=sql-server-ver15#levels-of-severity
The error severity 16 do not breaks the batch.
But if you use XACT_ABORT ON...
    SET XACT_ABORT ON

    BACKUP DATABASE [test] TO  DISK = N'X:\DB\SQL\2019\MSSQL15.MSSQLSERVER\MSSQL\Backup\test.bak' 
    WITH NOFORMAT, NOINIT,  NAME = N'test-Full Database Backup', SKIP, NOREWIND, NOUNLOAD,  STATS = 10;

    BACKUP DATABASE [test] TO  DISK = N'C:\DB\SQL\2019\MSSQL15.MSSQLSERVER\MSSQL\Backup\test.bak' 
    WITH NOFORMAT, NOINIT,  NAME = N'test-Full Database Backup', SKIP, NOREWIND, NOUNLOAD,  STATS = 10;

The second backup isn't ever reached.
Msg 3201, Level 16, State 1, Line 3
Cannot open backup device 'X:\DB\SQL\2019\MSSQL15.MSSQLSERVER\MSSQL\Backup\test.bak'. Operating system error 3(Impossibile trovare il percorso specificato.).
Msg 3013, Level 16, State 1, Line 3
BACKUP DATABASE is terminating abnormally.
Completion time: 2021-01-07T14:34:39.0700755+01:00