macos screen locks while I am working
It is likely that accidentally the lock screen keyboard shortcut, i.e. Control + Command + q is getting invoked.



It could be either you pressing the key sequence unknowingly or, one or two of the keys from the combination is stuck and pressing the third key by chance is invoking the sequence.

To resolve this issue, shut down your MacBook Pro, and repeatedly tap on each of the keys in succession and try to unstuck them. They turn on the MacBook Pro, resume your work and see if the problem goes away.