Here is the deal.
Both graphite and diamond are made of the element CARBON, atomic number 6 on the Periodic Chart.
Now, the crystalline structure that Carbon, and for that matter ANY element, takes depends on the pressure and temperature. These are called state variables, because they determine the STATE of the element. so that at very high temperature and low pressure, carbon is a gas!.... At somewhat higher pressure but still high temperature, carbon will become a liquid... finally in another part of the PT space, carbon will take on a crystalline form. The exact crystalline form or POLYMORPH depends, again on the pressure and temperature.
So at 1 atm pressure (like in the room you are reading this right now), GRAPHITE is the stable form of carbon at T= 298 K (or 25 deg C or approx 70 deg F). Now at room temperature (298 K) if one was to SQUEEZE the graphite in your pencil to about 15,000. atmospheres, then in fact graphite is no longer stable. Instead a new crystalline form, a mineral called DIAMOND is the stable phase or state of the carbon. So there is only a curve in PT space along which BOTH graphite and diamond are stable. This is called the equilibrium phase boundary and is an equation that relates P to T such that ALONG THIS CURVE BOTH DIAMOND and graphite coexist in stable equilibrium.
This subject is called chemical thermodynamics and it is a powerful tool for understanding the composition and energy exchange in many, many biological, chemical, geological, and physical systems.
No. Diamond and graphite have the same chemical composition (carbon), but they form in different situations. Graphite forms in a very low pressure setting, and diamond forms in a very high pressure setting (for example, buried deep within the Earths crust).