Often, people will use the word “which” when “that” is more appropriate. I think they do so because they believe “which” has somehow taken on a more formal or fancy tone (it’s a little bit like the way in which people use “whom” for “who” or “myself” for “me.”
A college professor of mine once gave a lesson teaching us to go on a which hunt, and with Halloween approaching, I thought it a fitting topic to resurrect (leaving us with, I suppose, some zombie whiches).
In general, it’s best to use “which” when the phrase it begins is providing extra information whose absence would not change the basic meaning of the sentence. A phrase beginning with “which” is often enclosed in commas. Consider these two sentences:
Vampire bats that don’t drink blood often go hungry.
Vampire bats, which don’t drink blood, often go hungry.
In the first sentence, we learn that vampire bats that refuse to eat blood go hungry, but there’s an understanding that vampire bats that eat other things may not go hungry. The “that” clause isn’t optional because it specifies a particular condition that must be met to render the sentence properly meaningful. In the second sentence, the “which” statement provides optional information. Vampire bats, whether they drink blood or not, often go hungry (the sentence posits).
Some would have written the first sample sentence above as “Vampire bats which don’t drink blood often go hungry.” It’s missing the commas, which provide a sure sign that the information is extra, but it’s still potentially confusing and is thus better said with a “that” than a “which.” So I encourage you to go on a which hunt when you’re writing and swap out any unnecessary whiches for thats.
For a more detailed breakdown of the rules, you might be interested in heading over here.