This happens because the gnocchi becomes lighter during boiling than when it was uncooked dough. Since it weighs more when first added, it sinks to the bottom. However, as it cooks, it sheds its water weight from inside but the air remains trapped in the middle, allowing the gnocchi to become light and fluffy (which is why we like it so much). Once this has happened, each piece then rises to the top of the boiling water, indicating that your gnocchi is ready for scooping out.