The "generations" of matter are mainly based on the electroweak symmetry group $\mathrm{SU}(2)_L\times\mathrm{U}(1)$.
All fundamental quantum fields are either a "singlet" or a "doublet" under the $\mathrm{SU}(2)$ part of this symmetry.
The left-handed fields usually form doublets, and the up- and the down- quark form the first, the strange- and the charm-quark form the second, and the top- and the bottom-quark form the three doublet we have for left-handed quarks. Similarily, the electron and its neutrino, the muon and its neutrino and the tau and its neutrino form the three doublet for the left-handed leptons.
Since there is a gradual progression of masses up->strange->top and electron->muon->tau, we call the fields in the up- and electron-doubles "first" generation, the next heavier ones "second" generation, and the heaviest one "third" generation, also because that is, due to the masses, the order in which we discovered them.
You can get a theory "of Standard Model type" with arbitrarily many generations - you can have $N$ quark doublets and $N$ lepton doublets, but you can't add a single quark (or lepton) that would behave like the others because you need a left-handed $\mathrm{SU}(2)_L$ doublet for the quark to behave like the other quarks (or a lepton to behave like the other leptons). You need to add the fermions in "pairs", either up-/down-type quark pairs or lepton/neutrino-pairs.
So far, there is no indication of more than three generations.