Because Netbeans (or the shell) will use two different threads for reading each stream: 1 for error and 1 for output. Thus there is no guarantee about how each thread will get scheduled (and the output printed)!
Both these threads are competing to append text to the console, and typically the output stream will flush() at the occurrence of a line-feed character. This is why you get lines of error and output text interleaved.
I should also probably say that the reason that two threads are used is because reading from a stream typically blocks the thread if no data is available. So if only one thread was being used to read from both output and error, it may block trying to read from output (while no output data is available) even though data is available on error.