Nether portals do not permanently "remember" what portal in the other dimension they connect to. Often this can result in multiple Overworld portals connecting to the same Nether portal, or in returning to the Overworld at a different portal than you started at.
This happens because whenever the player or other entity enters the portal, the game uses the coordinates of the entry point to calculate where to go in the target dimension. It then searches the target dimension for the closest portal and sends the player there, or if it can't find a portal close enough to qualify, it automatically creates a new portal as close as possible to the calculated coordinates and sends the player to it.
Here's how that works:
1. Start with the exact starting coordinates (Xstart,Y,Zstart) when entering the portal.
2. If traveling from Overworld to Nether divide by 8:
Xend = Xstart / 8 | Zend = Zstart / 8
If traveling from Nether to Overworld multiply by 8:
Xend = Xstart x 8 | Zend = Zstart x 8
In both cases, keep the Y coordinate unchanged.
3. Use the closest active portal within a 17×17 chunk area centered on the calculated coordinates (Xend,Y,Zend). If there is no portal close enough, create a new portal at a "safe" location. In some cases the game may create a platform around the portal over lava or water.
Note that when going from the Overworld to the Nether, it often happens that the target Nether coordinates are inside a mountain of netherrack from floor to ceiling, which leaves the game nowhere it can build a portal near the calculated coordinates. If this is the case and the game can't find an existing portal within the 17×17 chunk area, it creates a new portal as close as possible to the calculated coordinates, but this new portal may be displaced so far that it can't reach the original Overworld portal. This is one reason you sometimes can't return to the original Overworld portal you entered.
For a more detailed explanation visit the Minecraft Wiki.