There were two major reasons for this.
First, the Ottomans had had fairly shaky relations with the Allied Powers. This was especially true with regard to Russia. Russia had a strategic interest in controlling the Dardanelles and its desire to do so led to conflict with the Ottomans since the Dardanelles were in their territory. Since the Ottomans did not have great relations with Britain or France, they were inclined to side with the Germans.
Second, the Ottomans thought that German victories early in the war meant that Germany would win. They thought that if they got into the war on Germany's side they would be able to gain new territories for their empire after the Central Powers won the war.
So, the Ottoman decision to enter the war was based partly on a desire for more power and partly on the enmity between the Ottoman Empire and Russia.