Android - Why does OK Google voice search unlock Moto G4 Plus?
Trusted voice ("OK Google")
Trusted voice
When you say "Ok Google" from a secure lock screen and we're able to recognize your voice, you can ask Google to do things for you, or visit sites, without manually unlocking your device.
"OK Google" settings options (How to turn on/off OK Google and its settings (Trusted voice, etc)): Google Support
Source: Google
It is a feature as you can see in Lenovo forums
Long press on home screen and then press on settings.
Go to voice -> ok google detection and then turn off trusted voice.
Another post there says
Its not a bug. It just recognizes your voice but its not safe. As the feature is not accurate it may unlock even with others voice. Better turn off trusted voice. The voice command works even from lock screen works if your turn on option to Ok google from any app.