No, that is not guaranteed. The value of your investments can go up or down. If you withdraw your money at a time when the value is low, you may get back less than you deposited.
That is why it is wise to invest only with money you can set aside for a longer period. This gives your investments the chance to recover and grow in value over time.