Post 2020 errata: RAW it appears you do not attack, the attack is part of the "effect" of the magic
See https://media.wizards.com/2020/dnd/downloads/SCAG-Errata.pdf - the "as part of the action used to cast this spell" wording is gone, and with it the main justification for treating the attack as a component, not an effect of the magic (despite where it was placed in the spell description).
You brandish the weapon used in the spell’s casting and make a
melee attack with it against one creature within 5 feet of you. On
a hit, the target suffers the weapon attack’s normal effects and
then becomes sheathed in booming energy until the start of your
next turn. . If the target willingly moves 5 feet or more before then,
the target takes 1d8 thunder damage, and the spell ends.
... extra damage with levels
(And same first sentence for Green Flame Blade.)
(Not "within range"? So Spell Sniper won't let you benefit from a Reach weapon with it? Notice that range is now "self" (5ft radius), so clearly another intentional change.)
The fact that an erratum specifically changed "as part of the action..." to this more standard phrasing lends additional weight to the interpretation that the design intent is for Counterspell to cancel all of it, including the attack. Even moreso than if it had been phrased this way the entire time.
It now reads more like the attack itself is a result of the magic. Or happens after the casting (weapon used, past tense), not "as part of", in a way that the caster for some reason wouldn't carry through if the magic were disrupted, apparently... You could still make the argument that the attack itself isn't magic and that you'd still do it even if the magic were disrupted, but this is a significantly weaker argument.
The attack's regular effect doesn't include making the weapon or the damage count as magical for overcoming resistance or anything like that, so it's easy to argue the attack still isn't powered by the magic, for whatever that's worth. It's still a delivery mechanism for the magic. But it does look like we're meant to interpret it as an effect.
Old wording: Yes, you still attack. RAW and narrative justification.
This section is now obsolete, and was written based on the older wording, which provided most of the justification for treating this as an exception to the usual norm of the description text being all effect:
As part of the action used to cast this spell, you must make a melee attack with a weapon against one creature within the spell's range, otherwise the spell fails. ...
You are of course free to choose how these cantrips work at your table, but the "attack still happens" ruling is much harder to justify as RAW, post 2020. The rest of this answer was written before I was aware of the errata to Green Flame / Booming Blade, based on the original wording (which I think is neat, and an interesting difference from the way other spells work, but unfortunately isn't how the designers wanted them to.)
If you think disrupting the magic shouldn't stop a sword swing from still maybe connecting and hurting, this is how to explain that logic and explain how that's consistent with the rules. The other interpretation is also somewhat compatible with RAW, if you want to interpret words in very specific ways that seem unlikely to have been fully intended, given the phrasing of the cantrips themselves.
The RAW justification for ruling that Counterspell does stop the melee weapon attack from happening (e.g. @ThomasMarkov's answer) is based on interpreting the PHB wording as saying that everything in the spell entry after the headers is all "effects", in the sense that everything in that text is things that only happen if the magic is successful.
Each spell description in Chapter 11 begins with a block of information, including the spell's name, level, school of magic, casting time, range, components, and duration. The rest of a spell entry describes the spell's effect.
The rest of a spell entry describes the spell's effect.
That interpretation doesn't work even for some PHB spells like Burning Hands, where the text describes a somatic component. "As you hold your hands with thumbs touching and fingers spread, ..." Or Magic Stone "You touch one to three pebbles and imbue them with magic". Would CS stop you from even touching some pebbles? Or Vicious Mockery: "You unleash a string of insults laced with subtle enchantments at a creature you can see within range." Would CS shut you up so that not only is the save vs. psychic damage not needed, nobody even hears your insults?
Does "The rest of a spell entry describes the spell's effect" mean that every word of it is effects? No. A describes B doesn't necessarily mean that A contains nothing else. That choice of wording ("effect") is telling you that's where you should look to find out what the spell does, not trying to tell you there's nothing else in that part of a spell entry. It's also part of a summary of the layout, not a taxonomic classification into headers vs. effects.
So RAW, it's very possible to argue that the body of a spell entry isn't strictly limited to the (magical) spell effects that Counterspell would stop. Other effects of the process of attempting to cast the spell still happen.
Counterspell: 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
The rules are written in common English, with only some words being given specific technical meanings, like "action", "attack", "saving throw", etc. "Effect" / "effects" doesn't seem to be in that category, or if it is, it can also be used with its plain English meaning in other contexts.
"Effect" in this context should be understood as magical effect. I don't have any sources to back up this claim, but CS doesn't freeze your arms in mid-swing to stop you from making the touch part of an attack, or in this case the weapon-attack part of the casting process. The spell description even says you make that as a separate part of the Action you take to cast this spell.
If you do take the view that the entire description text is just "effect", in the same sense that CS is using the word, then you could say that ScAG presents these cantrips in a sloppy way, with non-effects (like the weapon attack as part of the same Action) in the "effect" section. That should have been listed as a component or with the casting time.
Additionally, as @illustro's answer points out, You attempt to interrupt a creature in the process of casting a spell can be read as saying you try to make something happen during the process of someone casting a spell. This will disrupt the magic but not freeze their hands in place or anything.
Narratively: the weapon attack is sort of a special spell component
Booming Blade and GF Blade aren't listed as having a Somatic component1 because apparently there aren't any fiddly hand gestures, just attacking with the weapon. But as the first thing in the description, in the same place we find some kind of gesture descriptions in other spells (Burning Hands hand position, or touching the target for many spells), we find that you make an attack as part of the process of casting the spell. (Not as a result of the magic taking effect).
If you were counterspelled while attempting to deliver a touch spell, you'd normally still end up touching the target.
There's no indication that this weapon attack is a result of the magic working, just a way to channel the magic into the target.
These ScAG cantrips are half melee, half magic. It seems normal that some of the damage can't be prevented with CS; casting one is just saying some magic words before / during making a melee weapon attack. (This is pure narrative interpretation on my part; that's the picture the text paints for me.)
You could argue that having the magic disrupted by CS will distract you from the melee attack so much that it automatically misses, if you want it to work that way instead. (In the unlikely even that someone spends a spell slot on CS on a cantrip, although perhaps they didn't know what spell you were casting.) So it's plausible to have a narrative explanation for how CS would stop the attack from working, other than having the attack powered by the magic (which isn't supported by the spell text).
Footnote 1: Fun fact: Listing the spell as having a Somatic component wouldn't require a free hand here, even without War Caster: the hand used for Somatic components can be the same hand that accesses a material component or focus. In this case, the weapon is the component, so that allows it to be in your hand the entire time you cast the spell, even if it did have a somatic component. Which they don't.
Not listing a Somatic component avoids the need for following this chain of rules logic to reach the conclusion that one can use it with a 2h weapon or sword+board, which is an advantage for players.
CSing one of these cantrips is probably such a rare thing that it has nearly no impact on overall balance of the cantrips, or the classes using them.
The cantrips are situational (less good against an unmoving or solo targets respectively) and not overpowered for most characters (AFAIK?). Having the minor benefit of only being partially stoppable with CS is not unreasonable and doesn't make them too strong.
Balance-wise, spending an Action on one of these cantrips means (at higher levels) you're giving up an Extra Attack. The ScAG cantrips are only really good for characters that are good at normal melee attacks and can cast spells.
Just making that happen already means you're probably not a pure caster class, so you already made compromises / tradeoffs / paid opportunity costs, like multi-classing, taking a feat to get the cantrip, or being an Eldritch Knight2. And of course choosing one of these as one of your cantrips, perhaps giving up Prestidigitation, Mending, or even Fire Bolt.
Ruling this way means that CS is very much not a good defence against them. But even if you rule that it does stop the attack, CS is not a great choice because the resource cost (a 3rd lvl spell slot) is relatively precious compared to the damage prevented, in most situations.
Footnote 2: Nothing against pure Eldritch Knights, just it means you had to choose that instead of other subclasses. They're pretty good. EKs specifically (at lvl 7) get to make a bonus-action weapon attack after using an action on a cantrip, so these cantrips are especially great for EKs from level 7 (war magic) up. (Extra attack x2 at 11th level is the same time you get an extra 1d8 on both damage rolls, so Attack vs. cantrip depends on your weapon expected damage vs. moving or two targets, and against high AC whether more chances for smaller hits are better than one big one...