Inside Protons and Neutrons
To understand certain types of nuclear reactions (especially those involving electrons, which normally have no business being in or near the nucleus) requires a little bit of nuclear physics.
We currently believe that both protons and neutrons are made of smaller particles called quarks. The six types (called flavors) or quarks are up, down, top bottom, strange and charm. Protons and neutrons only require "up" and "down" quarks. A proton is comprised of two “up” quarks (with +2/3 charges) and one “down” quark (with a -1/3 charge) giving a total charge of +1. A neutron is comprised of two “down” quarks (-1/3) and one “up” quark (+2/3) giving a total charge of 0.
However, it appears that sometime quarks can change from "up" to "down" or from "down" to "up". Occasionally, one of the “down” quarks in a neutron changes to an “up” quark. This process releases energy which is converted to an electron. This electron is then emitted from the nucleus as a beta particle. In other cases, an "up" quark in a proton absorbs or captures an electron (which is converted to energy) and the quark becomes a "down" quark, resulting in the proton becoming an electron.
Don't worry if none of this makes sense, as Richard Feynman (a Nobel Prize winning physicist) once told an audience of lay people he was speaking to, it ddn't make sense to him either. But, keep in mind that just because it doesn't make sense, that doesn't mean that it's wrong.