In general an initial state ##|i\rangle## will be unstable whenever there exists a final state ##|f\rangle##, such that:
1. ##|i\rangle## and ##|f\rangle## are connected by some interaction term ##\Gamma##. Namely, the matrix element ##\langle f |\Gamma| i \rangle ## is nonzero.
2. The potential energy of the final state is less than the energy of the initial state. Here we really mean that the mass of the particles in the final state are less than the initial state particle. Any excess energy will contribute to the kinetic energy of the final state particles.
For the mesons, the electroweak interactions always exist between quarks and antiquarks of the same or different type. For the same type of quark, we have electromagnetic interactions ##\bar{q} A_\mu \gamma^\mu q##, while for different quarks, there are weak interactions ##\bar{q} W_\mu \gamma^\mu q'##. These interactions can switch a quark ##q## to the same quark ##q## plus a photon or to a different type quark ##q'## plus a W boson. They can also destroy a quark-antiquark pair ##\bar{q}q## and create a photon, or destroy a ##\bar{q}q'## to create a W. The final state photon can create an electron-positron pair in the final state, while the W bosons will themselves decay to electrons and neutrinos in the final state, both of which are much, much lighter than the observed masses of mesons.
What is not explained by the above is why the mesons are heavier than electrons and neutrinos. It turns out that this is a consequence of the strength of the strong interactions, but there is no fundamental reason why. It is just an experimental fact.
The proton is stable because it is the lowest energy (lightest) configuration of 3 quarks. Because of charge conservation and color confinement, any electroweak interaction term like the ones above applied to the proton must lead to another final state composed of 3 quarks. Remember, the electroweak interactions either switch a quark for a quark + a gauge boson or replace a quark-antiquark pair for a gauge boson. So acting on a baryon ##q_1q_2q_3##, since we don't have an antiquark to destroy, we obtain another state
$$ q_1q_2q_3' + W,Z, \gamma. $$
There is no state ##q_1q_2q_3' ## with mass less than the proton, so a decay of this type is forbidden by energy conservation.
The strong interactions are a slightly different story. These have a form similar to the EM interaction, between same type quarks: ##\bar{q} G_\mu \gamma^\mu q##. The difference is the color indices on the quarks, which I haven't drawn in. The difference between this operator and the electroweak ones is that it operates on gluons. Since the proton is bound by the strong interactions, there are lots of virtual gluons present at any given time. So we can have strong interactions where we convert an internal gluon to a quark-antiquark pair. We can represent this as an interaction
$$ q_1q_2q_3g \rightarrow q_1q_2q_3 + \bar{q}_4 q_4.$$
So the strong interactions can generate an additional meson in the final state. However, since we still have the ##q_1q_2q_3## particle in the final state, energy conservation still prevents the photon from "decaying" in this manner.