When a mob or player steps onto the surface, their weight does nothing. It is when they interact with the pumpkin (trying to shear it, break it, or harvest a adjacent stem) that the magic happens.
The piston pushes the pumpkin, breaking it instantly for collection.