Anomaly and Nonplanar Diagrams in Noncommutative Gauge Theories