An object becomes electrically charged when there is a transfer of electrons between two objects. Electrons are negatively charged particles that orbit the nucleus of an atom. When two objects come into contact with each other, some electrons may move from one object to the other. The object that loses electrons becomes positively charged, while the object that gains electrons becomes negatively charged.
This transfer of electrons can also occur without direct contact between the objects. For example, if a charged object is brought close to a neutral object, the electrons in the neutral object may be attracted or repelled by the charged object. This can cause the electrons in the neutral object to move around, resulting in a separation of charges and the object becoming charged.
Another way an object can become charged is through the process of induction. If a charged object is brought near a neutral object, it can induce a separation of charges in the neutral object. This happens because the charged object creates an electric field that attracts or repels electrons in the neutral object. The result is a separation of charges, with one part of the object becoming positively charged and the other part becoming negatively charged.