A transaction groups statements so they succeed or fail together:
BEGIN TRANSACTION;
UPDATE products SET units_in_stock = units_in_stock - 10 WHERE product_id = 1;
UPDATE products SET units_in_stock = units_in_stock + 10 WHERE product_id = 4;
COMMIT;
Until COMMIT, the changes are visible only to your own session. ROLLBACK throws them all away, which makes it the undo button for a mistake you notice in time, such as an UPDATE that changed far more rows than expected. If a statement fails inside a transaction, the transaction can no longer commit, and you must roll back.
Outside a transaction most databases autocommit: each statement is saved as soon as it runs. PostgreSQL, DuckDB and Snowflake write BEGIN; SQL Server writes BEGIN TRANSACTION; MySQL accepts START TRANSACTION. A habit worth building: open a transaction before any manual fix, check the result with a SELECT, then commit.