Gnocchi are made of hydrophilic and hydrophobic ingredients. When they are uncooked, their specific weight is higher than water, therefore they sink in the to the bottom of your saucepan.
When they first contact boiling water, gnocchi start to cook on the outside – starch gelatinization and proteins agglutination – and the surface becomes impermeable.
Then the inside also starts to cook. The enclosed water evaporates, but as the steam cannot escape, it expands making the inside aerated and thick. The volume increases, the weight remains the same and therefore the specific weight decreases.
When the specific weight is lower than the density of water, gnocchi start to float, and the inner cooking is done!