the name attribute isn't really necessary when you are not sending data through it. The id of the form input element can fulfill the purpose of hooking the element with JavaScript and CSS.
The name attribute is used in the HTTP request sent by your browser to the server as a variable name associated with the data contained in the value attribute.
Here I'm taking example of extracting data with php in a login form. If you don't know php you wouldn't probably know $_POST and $_GET. For now just know that they are used to extract data sent with this HTTP request.
<form action="login.php">
    <input type="text" name="user" value="kittyCat">
    <input type="password" name="password" value="querty123">
</form>
Now in login.php file you can extract the data like this:
$userName = $_POST['user'];
$password = $_POST['password'];
here  user points to the fist input so  $username will be equal to the value of that input, which is "kittyCat". similarly $password will be equal to "qwerty123".