Though he eventually found enlightenment through meditation he went through a long trial and error process to get there.
Siddhartha was born a prince, and a prophecy said that he would grow to become a great king or a great religious leader. Obvious his father wanting him to succeed him as ruler, he cooped him up in the palace and indulged him completely, trying to spoil him and accustom him to the life of royalty; However, he felt as if he was incomplete and eventually he left his royal life and his family to explore the world.
Through his travels he found a reality that he was never exposed to: Aging, pain and suffering, death, and decomposition. He felt that the world was too full of suffering and vowed to find a way to end it. He spent years trying to find a way, learning and studying under monks and hermits of the time and far surpassing them but he never seemed to find the answer.
He tried giving up all his posessions, he beat himself, he begged, and he starved himself. He meditated under a long time fast to the point where he was pretty much at death’s door until a kid saved his life by feeding him. After that, he entered a clear state of meditation and realized that he’d been doing it all wrong.
What he discovered wound up being things like the four noble truths, that state that all desire is the root of all suffering; and the eightfold path as a guide to bring yourself closer to breaking the chain of suffering, and that the path to enlightenment is the “middle” way, no extreme indulgence or deprivation, but moderation.