Yes, there may be a way to get back into your Mac without erasing it, so your photos may still be recoverable.
The important thing to understand is that the forgotten Mac login password itself cannot be recovered or revealed.
Apple Support cannot retrieve the original password for you.
What you may be able to do is reset the login password and create a new one while keeping your existing account and data.
Your Mac login password is separate from your Apple Account password.
Depending on how your Mac is set up, macOS may let you reset the password from the login screen using your Apple Account or a FileVault recovery key.
If those options are not t available, Apple provides additional password-reset procedures through macOS Recovery, including the resetpassword utility. Apple: If you forgot your Mac login password
If FileVault is enabled, the recovery key can be especially important because it can provide a way to authenticate access to the encrypted data.
The FileVault recovery key is different from an Apple Account recovery key.
On macOS Tahoe 26 or later, Apple says the FileVault recovery key may also be available in the Passwords app on another Apple device using the same Apple Account and iCloud Passwords & Keychain.
Since your photos are important, do not choose “Erase Mac” yet.
Erasing the Mac removes the accounts and data stored on it. It should be considered only after the available password-reset and recovery options have been exhausted.
Apple Support can walk you through the official recovery options, but they cannot bypass the Mac's security or tell you what the forgotten password was if none of the available recovery methods work.
So, in simple terms: you can not recover the forgotten password itself, but you may be able to reset it and create a new password without erasing the Mac. Whether you can continue accessing the existing data depends on having an appropriate recovery or authentication method, particularly if FileVault is protecting the disk.