The submit button will refresh the page (reload it from server or cache). And the reloaded version will not contain the previously dynamically added rows.
To prevent the page from refreshing, you should "return false" and the function should be called onsubmit of the form instead of onclick of the submit button.
Code:
<form onsubmit="addRow(); return false;">
Name:<br>
<input type="text" id="name"><br>
Last Name: <br>
<input type="text" id="lname"><br>
Age: <br>
<input type="text" id ="year"><br>
<input type="submit" id ="buton" value="Submit">
</form>