They go to the undying lands, aka Valinor. Easternmost of the undying lands is the island of Avalonnë. West of Avalonnë is the main landmass of Valinor, with the Noldorin city Tirion, Valmar, the halls of Mandos, the gardens of Lorien, and so on. The Valar and Maiar dwell there in bless, with the Vanyar (the high elves, including Ingwë, High King of all elvendom), a remnant of the Noldor (deep elves) under their king Finarfin, and the Teleri (sea elves) who live on the shore at Alqualondë under their King, Olwë.
Originally the elves arose in Middle-Earth, but the Powers thought they were cool, and invited them to come home to Valinor with them to live. Most did. Some stayed in Middle-earth, like Legolas’ people.
Ages ago, most of the Noldor rebelled against the Valar, and left Valinor to make war on Morgoth, their great enemy in Middle-Earth. Galadriel was one of the rebels. Sauron was the lieutenant of Morgoth. This ended badly for the Noldor. They were long exiled from Valinor, until the end of the First Age.
The undying lands used to be physically joined to middle-earth, but back towards the end of the second age, when the Edain of Numenor (Aragorn’s people) rebelled against the rule of the Valar and sought to seize the undying lands for their own, the world was changed, and the undying lands removed from the circles of the world. Since then, only the elves, or those others allowed by the Valar could sail from middle-earth west by the “straight road” to reach the undying lands.
The time of the elves in middle-earth has passed, and it is doomed for those who remain there to slowly dwindle, or fade, in body and spirit. Or they can sail west to join their kin and the Powers, and await the world’s ending.
The spirits of all elves whose bodies are destroyed go back to Valinor, to the halls of Mandos, where they hang out, and may eventually get issued new bodies. None of the Powers know where the spirits of men end up, as they leave the circles of creation. Hence the “gift of men”, which the Powers themselves may come to envy as the ages wear on.
BTW, a mortal setting foot on the undying lands would not become immortal himself.
Hope that clarifies.