Common (incorrect) perception of grounding
It is a common believe that grounding a conductor makes it electrically neutral. Most electric engineers trained in classical electrodynamics would consider the Earth as a large and neutral pool of charges. Any ordinary conductor connected directly to Earth or, in other words, grounded would lose its charge and assume potential of the ground.
That makes perfect sense in terms of statistical mechanics. A tiny, by comparison, charge of the sample would spread evenly over the sum of surfaces of the sample and of the Earth leaving the sample practically charge-less .
Also the electric potential of the grounded conductor would match the potential of the ground. After all this why we ground things, to pin their potential to something steady, right? Besides it is easy to verify with any voltmeter.
When probes of a voltmeter are connected to the ground on one side and to the grounded conductor on the other, it is the same as if they were shortened. The voltmeter will show 0 V.
Nature doesn’t follow the course of electrodynamics
In practice a grounded sample is inevitably charged. Conductors made of different materials will charge to different extent. For example, gold would charge negative when grounded while magnesium will be positively charged.
Moreover, despite the apparent evidence to the contrary, the electric potentials of the ground and the sample are usually off by a value of order of 1 V. This is only evident when Contact Potential Difference (CPD) is measured between the sample and ground.
What really happens
Surprisingly, quantum mechanics is to blame for that macroscopic effect.
According to QM, each conductor, Earth included, has its own set of electronic energy states. Those states are occupied by conductor’s electrons up to some imaginary energy level, called Fermi level. The Fermi level $E_F$ separates the occupied low energy states from high energy empty states.
When two conductors are electrically connected and in equilibrium with each other, their Fermi levels must coincide. This is because electrons naturally flow from higher to lower Fermi level$^*$. Influx of electrons brings down an electric potential inside the material and thus shifts its Fermi level up. Outflow of electrons moves the Fermi level down for a similar reason. See this post for explanations.
As far as Fermi levels go, Earth can be treated as a giant ball of aluminum. It has Fermi level higher than gold and lower than magnesium.
Any conductor connected to Earth would adjusts its original Fermi level $E_F^0$ to the Fermi level of the ground $E_F^G$ $^{**}$.
The only way to do that is to adjust its electric potential accordingly by transferring electrons between the conductor and the ground. The transfer stops once the equilibrium is reached and the sample is properly charged with charge $Q$.
$^*$ And this also why ordinary voltmeters measure Fermi level difference rather than electric potential difference.
See how voltmeters are build.
$^{**}$ The Fermi level of Earth doesn’t move much due to the large discrepancy between sizes of the planet and of the sample.