Password managers guess what a field is for. On a sign-up page they sometimes fill in the saved password instead of suggesting a new one. Two values of autocomplete remove the guessing.
<!-- sign up or change password -->
<input type="email" name="email" autocomplete="username">
<input type="password" name="password" autocomplete="new-password">
<!-- log in -->
<input type="password" name="password" autocomplete="current-password">
new-password tells the browser this field wants a password that does not exist yet. Browsers and password managers use it to offer a generated password and to avoid filling in an existing one. current-password is for the login form, where filling in the saved password is exactly what you want. Marking the username field with username helps the manager store the pair correctly, even when the username is an email address.
I’d also use new-password on the “confirm password” field, which MDN mentions as one of its uses.
A related trap: autocomplete="off" on a password field to block autofill. MDN notes that browsers may ignore it on login fields, because blocking password managers pushes people toward weak passwords. And made up values to trick autofill only stop the browser from recognizing the field at all, so the right value is nearly always the better fix.
Further reading: MDN: autocomplete attribute