In normal condition the number of protons and electrons in any atom is equal. But every atom has got affinity for getting excess electrons. This affinity for excess electron is different in different substances. That is why when two bodies are brought in contact with each other, the body which has greater affinity for electron collect electrons from other body and gets charged negatively this happens when a glass rod is rubbed with silk.
[Fig: 1] [Fig: 2] [Fig: 3]
[Fig: 1] Silk has more electron affinity than glass and as such these two are rubbed together, the electron of glass goes to silk. As a result, the silk gets charged negatively and the glass rod becomes positively charged. This is why glass rod attracts pith ball [Fig; 2].
Again when a rod of ebonite or polythene is rubbed with flannel, polythene rod gets charged negatively and the flannel becomes positively charged. Because polythene has more affinity for electrons than that of flannel and so when they are rubbed together free electrons of flannel moves to ebonite or polythene and gets charged negatively [Fig: 3].