Ensure the mob is fully contained. If a part of the mob's hitbox is clipping through the piston, the game might not register it as "trapped."
Place a temporary block two blocks above the pressure plate. Attach a solid block to the bottom of that temporary block. Break the temporary block.
Tips & troubleshooting