The idea of a new friend code for each new save (or game card for that matter), is so that everyone who shares one DS, can play online on that DS at different times, without affecting each others friend list. What is really happening, is that the first time you connect with a given game card, the game is getting a new friend code from the Nintendo WFC server, and putting it into the game card.
The only thing that affects if the friend code will be the same or not on next connection, is the WFC ID stored in the current DS. If the WFC ID is the same, then the friend code for that game card will remain the same. This is why you can transfer your WFC ID info to another DS, then play your game card on that DS without affecting your friend code.