First, we have to recognize that the United States did not actually avoid World War I. It, of course, became a participant in the war, albeit only 3 years after the war started. The US did, however, avoid war for those three years. It did this mostly through geography and partly through political choices.
The main thing that allowed the US to avoid involvement in the war was geography. The US is, of course, separated from Europe by the Atlantic Ocean. Therefore, the combat would not spill over onto American soil. The conflict would also not directly threaten the country. This allowed the US to remain neutral in a way that Belgium or Britain, for example, could not.
However, the US also made choices that kept it out of the war. Most notably, it chose not to go to war with Germany over the issue of unlimited submarine warfare until 1917. The US could have, if it so desired, found a pretext for war long before that. Because so many Americans wanted to remain neutral, the US government made political choices to avoid war until 1917.