Carbon is the only element that can form so many different compounds because each carbon atom can form four chemical bonds to other atoms, and because the carbon atom is just the right, small size to fit in comfortably as parts of very large molecules.
Carbon atoms can share not only a single electron with another atom to form a single bond, but it can also share two or three electrons, forming a double or triple bond. This makes for a huge number of possible bond combinations at different places, making a huge number of different possible molecules. And a molecule that differs by even one atom or one bond position is a molecule of a different compound.