Here's the relevant rules for counterspell (emphasis mine):
You attempt to interrupt a creature in the process of casting a spell. If the creature is casting a spell of 3rd level or lower, its spell fails and has no effect.
And for dispel magic (emphasis still mine):
Choose one creature, object, or magical effect within range. Any spell of 3rd level or lower on the target ends.
Neither of the spells above can affect Wild Shape because it is not a spell. This is because something is only a spell if it's called a spell (see this related question for why), and the rules for Wild Shape don't call it a spell. It doesn't matter that Wild Shape is magical in nature; it is simply not a spell. This is addressed in the Sage Advice Compendium, the official source of rules clarifications (bracketed context mine):
Can you use dispel magic to dispel a magical effect like a vampire's Charm ability or a druid's Wild Shape? Dispel magic has a particular purpose: to break other spells. It has no effect on a vampire's Charm ability or any other magical effect [such as Wild Shape] that isn’t a spell.
If you want to cause non-spell magical effects to end, take a look at the antimagic field spell. With just a breezy 8th-level casting, it can suppress all magical effects (except those created by artifacts or deities) including non-spell effects such as Wild Shape. The effect of Wild Shape would be suspended while the druid is within the field. The exact meaning of this suspension is somewhat left to the DM, but probably the druid would revert to their normal form while within the field, then regain their beast form as soon as they exit the field, using the respective hit points of whichever form they are in.