Many applications are much more complicated than your example. On the other hand, even your example could be simplified: remove the call to mysql_num_rows() and just test:
if ($query = mysql_query($query))
It'll work because with a SELECT query, mysql_query() returns FALSE if no rows were found.
So one answer to your question is incomplete knowledge.
Another reason is varying experience levels: the more experienced you are, the more likely you are to know shortcuts, and thus write shorter code.
Yet another reason is because sometimes people find the long way more legible. This, of course, is somewhat relative, and depends not only on your experience but your personal coding style as well, not to mention background in other programming languages. While the somewhat PERLish
$x = ($y != 0) ? 1/$y : $y/1;
is functionally the same as
if ($y != 0)
$x = 1/$y;
$x = $y/1;
, not everyone is going to use the first way - despite the fact that it is effectively the same and is much more compact - and to some, perhaps it is more legible.
Another reason for complex code is because you can't plan explicitly for every possibility, so instead you plan for the one or two right/safe ones, and then call the rest errors. But you can't give people the standard error messages: not only do error messages turn people off, but they could also provide very useful information to an attacker.