name
identifies form fields* ; so they can be shared by controls that stand to represent multiple possibles values for such a field (radio buttons, checkboxes). They will be submitted as keys for form values.
id
identifies DOM elements ; so they can be targeted by CSS or Javascript.
* names also used to identify local anchors, but this is deprecated and 'id' is a preferred way to do so nowadays.