Will the algorithm change affect the blockchains to be generated or saved?
How to deal with the new-generated blockchains and the old blockchains if the formers are changed?
Miners and nodes are updated ahead of time with new software. This software is hard coded to know in advance the block height at which the mining algorithm is agreed to change over. Block height is simply a count of the number of blocks since the very first block ever mined (also known as the genesis block). When the block at the agreed upon changeover block height is mined, it is simply mined using the new algorithm and nodes know to check for an alternate proof of work for that block onwards. It's all the same blockchain, but it's verified using different methods according to which part of the blockchain is being verified.