lock() returns a temporary shared_ptr object. When this object is created the use count is increased by 1 because there is now one more shared_ptr pointing to the object.
The temporary shared_ptr object is then assigned to _B. The use count of the object pointed to by _B before the assignment will be decreased by 1 (if it drops to 0 it will be deleted) and then the use count of the assigned object will be increased by 1. In this case _B points to the same object before and after so the use count stays the same (-1+1=0).
At the end of the line the temporary shared_ptr object is destroyed so the use count is decreased by 1.