As with attaining any goal, you can’t go about putting an end to suffering and arriving at enlightenment just any old way. If we throw a stone up into the air, we should not be surprised if it falls on our head. In the same way, when we commit any act, whatever it may be, we can only expect that sooner or later it will produce an effect. Thus it is logical that if we want to free ourselves from suffering, we have to perform certain actions and refrain from certain others. The law of the causality of actions is the very foundation of the teaching of the Buddha, who proclaimed:
Avoid the least harmful act,
Perfectly accomplish the good,
And master your mind.
That is the teaching of the Buddha.