Custom menu breaks down

Custom nav menus are also a query, which you end up altering with that code. Your best bet is to check to make sure it’s the main query, e.g. by globaling $wp_the_query and doing a strict comparison with $query or doing $query->is_category() instead (I believe that works – somebody will smack me down if it doesn’t). In 3.3, there will be the very convenient is_main_query().