(Reg Mitchell and Barry Shell also contributed to this answer.) An element is determined by the number of protons in the nucleus, not the number of electrons surrounding the nucleus. The nucleus is composed of neutrons and protons, and the protons determine the element. Elements typically have the same number of electrons as protons. The chemical properties of the element are determined by the electrons surrounding the nucleus.
Depending upon the configuration of these electrons, the element has different properties. Electrons exist in "layers" around the nucleus. These layers are called "shells" and nature loves when the outer shell is filled. The first shell can have one or two electrons. It is full when it has two. That's why hydrogen which has one electron always pairs up with another hydrogen atom and occurs naturally as H2. It shares it's electron creating a complete outer shell. The most important electrons in an atom are those in the outer shell. The first shell has 2, then the next shell has 8 electrons, and so does the third. The fourth has 18. Oxygen gas which consists of two oxygen atoms sharing electrons is stable because the atoms have filled their second shell. Oxygen atoms have 8 electrons (the inner shell has 2, and the outer shell has 6). Oxygen loves to obtain or share two more electrons to fill up it's outer shell by borrowing from another atom. You'll need to learn a lot more chemistry to understand why, but there are very good theories for this now. Elements with similar outer configuration of electrons have similar chemical properties.
The reason an element exists as a gas, liquid or solid again has to do with size/shape and number of electrons in the outer shell. Gases like Hydrogen (H2), Helium (He), Nitrogen (N2), Oxygen (O2) all have saturated outer shells, that is 2 or 8 electrons. This means they are non-polar (no charges) so any forces affecting them when they are present in large numbers and contacting each other are all very weak forces; the molecules are like small spheres with very little contact so there is no adhesion between molecules so they exist as gases. Carbon which has similarly low atomic number has outer shells that become satisfied by sharing electrons in many directions with other atoms. For instance, carbon atoms have 4 electrons in the outer shell. Carbon wants to have 8, but two carbons cannot share 4 from each. That is, C2 does not exist. So carbon forms a giant network of atoms where 4 carbons are surrounded and bonded to four others as in diamond. The result is a massive crystal solid with lots of contact between each atom, so it is very strong and has a very high melting point. Liquids are in between, for example carbon tetrachloride, (A carbon with four chlorines all around sharing one electron each). It's a bigger molecule so there is more contact and attractions between molecules, so more molecules stick together and you get a liquid rather than gas. The molecules are not bonded together, so they can move about each other and you get a liquid rather than solid. In a solid molecules are more or less held in place by bonds or charges (as in a salt).