[J]ust as I consider that others sometimes go astray in cases where they think they have the most perfect knowledge, how do I know that God has not brought it about that I too go wrong every time I add two and three or count the sides of a square...?
How do you know that God has not likewise brought it about that you go wrong every time you reflect on the necessary implications of your own thinking or doubting? It is admittedly nonsensical to seriously entertain one's own non-existence, but it is no less nonsensical to seriously entertain that the second successor of 3 is not 5.
One objection (a friend pointed out to me) is that we often suppose impossible things to be the case, at least for sake of argument. I take it the purpose of this practice is to highlight some important partial truth. But we can do this just as well in case of the cogito. ("Suppose, for sake of argument, that I don't exist. So my parents only have four children!")
So I think the apparent difference is merely psychological. In case of any incoherent supposition, the thought experiment eventually breaks down, if pushed to the point where the contradiction becomes explicit and unavoidable. But some contradictions are better hidden than others. It seems easier to suppose that there are finitely many prime numbers, for example. We can create a rough mental model which seems (prima facie) to accommodate this possibility, and it will take a bit of pushing before it explodes on us. Denying one's own existence, on the other hand, leads to much more obvious and immediate difficulties. We can't even pretend to make sense of this, the way we can when entertaining the denial of some more complicated mathematical thesis. But it's worth noting that even the latter is mere pretense. There's isn't really anything there for us to grasp -- the deep incoherence renders the scenario ultimately unintelligible -- we are merely playing along for the sake of argument; drawing inferences and highlighting partial truths. You can't, strictly speaking, suppose gobbledygook. So logical necessities are on no less firm footing than Descartes' cogito.