I don’t quite understand the question. All electrons and protons have charges. The charges do not “form”, they are already there. They are part of every atom. The attraction between electrons and protons is what holds every atom together. Quantum mechanical laws keep them a certain distance apart.
When there is an imbalance between protons and electrons, ions are formed with the charge depending on whether the ions have more electrons or protons.
I hope this helps a little more. Thanks for asking.