Hello vani130,
It sounds like you're experiencing some unexpected behavior with the Notes app. You can check out more information on how this is supposed to work here: Change your password for locked notes - Apple Support.
If you’re using the same password for your On My Mac account and your iCloud account, you can keep both passwords the same when you change the password for your iCloud account. If you choose to do so, Notes automatically changes the On My Mac password to the same password as your iCloud account.
Additionally, this page offers information about locking your notes on your Mac: Lock your notes on Mac - Apple Support.
If you've followed these steps and still experiencing unexpected behavior, you'll want to reach out to Apple directly for further troubleshooting. You can reach out to them by clicking here: Contact - Official Apple Support or over the phone by calling the number that is most local to your region: Contact Apple for support and service - Apple Support.
We hope this information helps you out.
Cheers!