Confused between 2 phase locking and 2 phase commit
These are two different things that have two different goals.

The two-phase locking protocol is designed to guarantee serializability for transactions that access concurrently a single, centralized database, using a locking mechanism. So its goal is to maintain the consistency of a centralized database, avoiding “bad” interferences among concurrent, different, transactions that operate on the same data.

Two-phase commit protocol, instead, concerns the execution of distributed transactions is a distributed database, and guarantee that a single distributed transaction, seen as “set of processes in a network system”, coordinates the work of those processes even in case of temporary system failures (for instance, in case of network failure). So the protocol has the objective of avoiding situations in which a certain transaction commit its operation is a node (that is in a part of the distributed database), but aborts in another node (that is in another part of the same distributed database).

Of course you can see both protocols as having the final objective is to maintain the “consistency” of the database, centralized in a case, distributed in the other. But this is really a generic point of view.