Accidently said:
3 generation is required for anomaly cancellation ...
That's not quite true.
The completeness of the multiplet {electron, electron-neutrino, up-quark, down-quark} and the completeness of corresponding multiplets in all higher generations are required. So two generations with {electron, electron-neutrino, up, down} and {myon, myon-neutrino, strange, charm} are perfectly valid. What is ruled out due to anomaly cancellation
is an incomplete multiplet, i.e. the situation we had about 20 years ago, namely {tau, tau-neutrino, *, bottom} where the * indicates the missing top.
There is no requirement for the second, third or forth generation; theoretically they are all unnecessary waste ;-) Already after the discovery of the muon Rabi asked "who ordered that?".
Accidently said:
But there are still papers about the 4th generation, what is the reason?
It's allowed theoretically, just as the 2nd and 3rd one.
I am not absolutely sure but I thought that a 4th generation is almost certainly ruled out experimentally (the 4th generation particles would be too heavy to be produced directly in colliders, they may by too instable to be detected directly, but they do contribute to loops even at lower energies therefore there are indirect indications regarding the number of generations).