How can carbon and hydrogen atoms both be composed of the same elements but be different compounds?
You speak of isomers, for which carbon compounds, hydrocarbons, offer a great deal of opportunity and variety.
To illustrate isomers, I will just consider the alkane series, whose general formula is
For methane, ethane, and propane,
Because the carbon skeleton is different, these are distinctly different chemical compounds, even tho their formula is identical.
And now we go to the isomers of pentane:
And here we have 3 different isomers possible, all with similar chemistry, admittedly, but each isomer has DISTINCT physical properties: the boiling point is perhaps the one that is most significant. The longer the chain, the more involatile should be the pentane, and the higher the boiling point.
And now go to
The larger the formula, even with respect to the simple alkanes, the more isomers can be generated. Substitute the chain with a few heteroatoms, and the number of compounds that can be generated increases substantially. Anyway, read the appropriate section of your text, and you can put further queries here.