It prints 6 lines because the out loop controls the inner loop.
Write it like this:
The extra println and brackets for the loops may help make things clearer. With the exception of the added print statement, this is equivalent to the code you posted, and the extra println has no effect on the numerical lines that are printed.
Run the code and then get out a pencil and paper and trace through the code. Write the name of both variables, and then trace through the code. When a variable changes, write the change down. Once you do this
you should be able to tell how the outer loop is affecting the inner loop. Make sure the program output matches what you have on paper.
The only time the print statement should print 3 times is when count=3, but it still has to deal with the cases when count=0, count=1 and count=2. When count=0, innercount is never less then count, so control never drops into the body of the inner loop, instead it returns to the outer loop where count is incremented. Hopefully this will get you started in the right direction.