dnd 5th – Should a cantrip be learned like level 1-9 spells as a wizard?

Cantrips do not count against the two spells you learn when leveling up

The Spellcasting feature of the wizard indicates:

Whenever you gain a wizard level, you can add two wizard spells of your choice for free to your grimoire […]

However, it's important to note that this is in the "1st level and higher spell learning", which tells us that this applies when learning 1st and higher spells – and therefore do not apply to cantrips, which are level 0 spells:

Each spell has a level from 0 to 9 […] Cantrips – simple but powerful spells that characters can cast almost by heart – are level 0 […]

In fact, the wizard section on "Cantrips" states:

At the 1st level, you know three cantrips of your choice in the wizard's list of spells. You learn additional assistant cantrips of your choice at higher levels, as listed in the Known Cantrips column of the Assistant table.

Looking at the Wizard table, we see that at level four, you go from knowing three cantrips to knowing four, and therefore you end up learning an additional cantrip when you reach level 4. This doesn’t ; does not affect the two spells won at any Wizard level because cantrips are not 1st level spells or higher.

Another thing to note is that cantrips are not part of your grimoire at all, so they could not be the two spells you add to your grimoire:

[…] Your spell book is the repository of sorcerer spells that you know, with the exception of your cantrips, which are fixed in your mind.