Banker algorithm is used to avoid deadlock by checking whether a resource allocation may cause the system to be deadlock or not, while the lock is used to solve the critical section problem, i.e., to avoid more than one process can enter the critical section at the same time.
Locking itself cannot avoid/prevent deadlock without combining with other deadlock solutions.
And as deviantfan's comment: no restriction on the lock acquisition in most of the OSs. The following is a simple example in which the system may be deadlock even the use of lock is valid:
P1: ....; lock(fileA); lock(fileB); .... unlock(fileA); unlock(fileB); ....
P2: ....; lock(fileB); lock(fileA);..... unlock(fileB); unlock(fileA); ....