Quarks have color charge, so they have strong interactions, and strong interactions are what cause quarks to combine into a hadron. Residual strong interactions bind hadrons together to form a nucleus.
Quarks have flavor charge, so they have weak interactions. Flavor (u, d, c, ...) is never altered in strong, electromagnetic, or in neutral weak (Z boson) interactions.
For example:
All the quarks on the left side also appear on the right side.
However, when a quark emits a (virtual) W+ or W- boson, it must change its electric charge and thus, its flavor. The predominant weak processes involve transitions between quarks in the same generations, but rarer transitions also occur between any +2/3 quark and any -1/3 quark.