You know, you're not making any friends when you ask questions like that.
The real reason, of course, is that if he locked the door and took the key with him, like any normal person, or if he even locked his computer when he walked away, like most computer types, Nancy wouldn't be able to get in and we wouldn't be able to solve the case. But let's pretend it's because he isn't really a security guy at heart; he's a physicist, and he knows precisely what that alarm means and how urgent it is to respond when it goes off.