How are quarks elementary when they can become leptons?

Particles are called elementary if they are not made up of other particles. However, interactions can change an elementary particle into another kind of elementary particle.

Quarks and leptons are currently believed to be elementary. (This could change if we could observe particles interacting at higher energies than, say, the LHC can achieve.) However the weak interaction can, for example, turn an up quark into a down quark, and an electron into an electron neutrino. When they change, they either emit or absorb a W or Z boson, the particles that carry the weak force.

A quark can’t directly turn into a lepton, but two quarks can indirectly produce two leptons. For example, an up quark and a down antiquark can turn into a $$W^+$$ boson, which can then turn into a positron and an electron antineutrino.

When an elementary particle like a muon decays into other particles, it doesn’t mean that those particles were inside the muon before it decayed. It means that the muon changed into a muon neutrino, emitting a $$W^-$$ boson in the process, and then that $$W^-$$ boson changed into an electron and an electron antineutrino.

We have a plethora of data on particle interactions since last century, and laboriously have come up with a mathematical model for particle physics that works, i.e. it gives the right numerically answers for these data and, important, is successful in predicting new data, as recently happened with the Higgs boson. It is called the standard model for this reason and has an elementary particle table.

These are what the successful model uses as elementary particles (together with their antiparticles), i.e. point particles carrying quantum numbers and masses that , when used to get the crossection of an interaction or the decay width or.. work beautifully and the model is continually validated.

In this model the elementary particles interact with the three interactions according to their quantum numbers, and some such interactions and the energy supplied by their masses allow them to decay to other elementary particles. The Z and W and the Higgs also decay into lower mass elementary particles.

So the answer is that it is a model that defines what elementary particles are which is working very well.

If in the future a string theory model, for example, can embed the standard model into vibrations of a string, there will be only one elementary entity, the string.

It is all in the model.