I assume you're talking about mesons (e.g. up-antiup quark pairs). If I'm not mistaken it's because the quarks have different colour. Quarks can be blue, red or green as well as be up or down (this isn't actual colour, just another category to distinguish quarks from each other). It's the same reason you can have a 2 up, 1 down quark combo in a proton and 2 down, 1 up in a neutron which initially looks like it breaks the Pauli exclusion principle (no two particles in a system can possesses an identical set of quantum numbers) but if you assign colour to the quarks the Pauli exclusion principle is maintained (the accepted arrangement is one blue, red and green quark per nucleon). The reason the up-antiup pair don't cancel out is because the are not exactly a matter-antimatter pair.
Steve