Your question touches the question of ontology in particle physics. Historically we are used to be thinking of particles as tiny independent entities that behave according to some laws of motion. This stems from the atomistic theory of matter, which was developed some two thousand years ago from the starting point of what would happen if we could split matter in ever smaller parts. The old Greeks came to the conclusion that there had to be a limit to that splitting, hence the atom hypothesis was born.
This was just a philosophical idea, of course, until around the beginning of the 19th century we learned to do chemistry so well that it became obvious that the smallest chunks that matter can be split into seemed to be the atoms of the periodic table. A hundred years later we realized that atoms can be split even further into nuclei and electrons. What didn't change was this idea that each chunk had its own independent existence.
This idea ran into a deep crisis during the early 20th century when we discovered the first effects of quantum mechanics. It turns out that atoms and nuclei and electrons do not, at all, behave like really small pieces of ordinary matter. Instead, they are behaving radically different, so different, indeed, that the human imagination has a hard time keeping up with their dynamic properties.
For a while we were in a limbo regarding our description of nature at the microscopic scale. It seemed like we could cling to some sort of "little weird billiard ball with mass, charge, spin etc. properties" kind of theory for electrons, but as time went by, this became ever more hopeless. Eventually we discovered quantum field theory, which does away with the particle description completely, and with that all the ontological problems of the past century have disappeared.
So what's the new way of describing nature? It is a field description, which assumes that the universe is permeated by ONE quantum field (you can split it up into multiple components, if you like). This quantum field has local properties that are described by quantum numbers like charge. This one quantum field is subject to a quantum mechanical equation of motion which assures that some properties like charge, spin, angular momentum etc. can only be changing in integer (or half integer) quantities (in case of charge it's actually in quantities of 1/3 and 2/3 but that's a historical artifact). Moreover, this field obeys symmetry rules that leave the total sum of some of these quantities unchanged or nearly unchanged. Charges in particular can only be created on this field in pairs such that the total charge remains zero.
So now we can answer your question in the language of the quantum field: the electron gets its charge by the field allowing to create one positive charge state and one negative charge state at the same time, leaving its total charge zero. This process takes some energy, in case of the electron-positron pair a little over 1MeV. Every other property that is needed to uniquely characterize an electron is created in a similar way and at the same time. The elementary particle zoo is therefore nothing but the list of possible combinations of quantum numbers of the quantum field. If it's not on the list, nature won't make it (at least not in form of a real particle state). Our list is, of course, at best partial. There are plenty of reasons to believe that there are combinations of quantum numbers out there that we have not observed, yet, but which are still allowed.