It happens in this order:
First page load
PHP tries to access $_POST['name'] which triggers an undefined index notice because you haven't submitted the form yet
something is set to "" (because nothing has been submitted)
You submit the form.
On submit triggers, console logs out an empty string.
Second page load
Because the form was submitted, the page load now sees $_POST['name'], so no error.
something = whatever you submitted in the form.
You submit the form.
On submit handler triggers, your console spits out the original submitted value from the first submission