Program for NXT golf robot not looping properly
Looking at your code, there are a few things that you need to consider.

Firstly, you have a while (true) loop which will run infinitely.
The first thing you have after the loop is OnFwd(...) which will turn motors A and B on.

Together, this means that whatever you do next, when then you will run the code again, turning on motors A and B.

The next thing to be aware of is that Wait(2000) is milliseconds. 2000 milliseconds is 2 seconds, so you will only turn motors A and B off - stopping the robot - for either half a second, or 2 seconds before the loop starts again, and the robot starts moving again.

In the case where both if statements are true (presumably when it detects a red ball - but I haven't double checked either the Sensor or SensorUS commands), the robot will stop, the motor C will start, then 2 seconds later the robot will start again.

I would suggest increasing the values in the Wait statements (you could use time constants such as SEC_5), and adding a break; after the Wait(2000);