Until now, a student who opened a test through Anyone with the link just typed their name and started — and you linked their results to the right account yourself afterwards. New tests now ask students for their email address first. They get a short code by email, enter it, and land straight in the test, so every result is tied to a student account from the start.
You'll find the switch under Anyone with the link, in the window that opens after publishing and under Settings → Access & sharing: Require students to sign in with their email. It's on for new tests; existing tests keep working as before until you turn it on.
Signing in also makes retakes count properly, since attempts are tracked per student. More in the guide to sharing a test.