Well it's simple, in web whenever a page is created for login or for signup there are few things that kept in mind.
1-The user input is taken in forms.
2-Variables are created to take your input,that depends on what are the rules for inputs.
3-In web a tag
<input type="password" class="inputtext" name="pass" id="pass" data-testid="royal_pass"> in this snippet the
type = "password"
tells you are going to enter password
So whenever you are going to fill a login page the browser detects and asks you to save the password.Then Browser checks for username, the tag is also used for user name. Basically you can say that input works as a variable, whose name is
"pass" to take your input and proceed.