It's all due to a process called osmosis and the movement of water from a high water potential to a place of low water potential, passing through a partially permeable membrane. So what does this mean? If you have a really high concentration sugary solution, that is said to have a low water potential (think that all the water is interacting with the sugar). If you have a low concentration sugary solution, this has a high water potential. Therefore, water wants to moved from where there is lots of available/free water molecules to where there aren't that many. This means the water moves from the low sugar concentration solution to the high sugar concentration. You can think of the water always moving to try and dilute the most concentrated side and it will do this until both sides are balanced. In terms of the potato, depending on the concentration of the sugar solutions, when the surrounding solution contains a lower concentration of sugar (so a high water potential, lots of free water). The water passes through the potato cell membrane (a partially permeable membrane) into the potato, making it swell and increase in mass. If there is more sugar in the surrounding solution than the potato sample, the reverse happens. The water passes out of the potato, through the membrane and into the solution - meaning the potato mass decreases.