In Sonic Adventure 2 the mix-up happens because of silhouette and scale — both are hedgehogs of the same height and build, and at a distance or in poor light that's enough. Amy makes the same error.
That said, it doesn't hold up well under scrutiny. The games repeatedly have characters identify Sonic as "the blue hedgehog," which is a detail Shadow plainly doesn't share. The confusion is a plot convenience more than a convincing mistake.