How Nether portal coordinates work
One block traveled horizontally in the Nether equals eight blocks in the Overworld. Divide Overworld X and Z by 8 to find a Nether target; multiply Nether X and Z by 8 for the return destination.
Minecraft may connect to an existing nearby portal instead of creating one at the exact target. Building both portals near the calculated coordinates reduces incorrect links.