Firstly, 'pre_get_posts' is an action and not a filter. That's the main problem to start. Secondly, you need to set conditionals for the context.
add_action('wp', 'custom_post_count');
function custom_post_count($query){
if($query->is_home || $query->is_front_page){
$query->set('posts_per_page', 5);
}
return $query;
};
The previous example is if you want to use this once in your functions.php without touching your template files. As far as affecting every query, if you don't create a new query, every loop with inherit the pre_get_posts $query. That's why I use query_posts() to create a new query in the following example.
Custom Loops
This is how I do custom loops:
$args = array(
'posts_per_page' => 5
);
query_posts($args);
if(have_posts()): while(have_posts()): the_post();
endwhile; else:
endif;
wp_reset_query();
Just place query_posts() above the loop and wp_reset_query() at the end of the loop.
Hope this helps you out. :)