In his previous two terms, Teddy Roosevelt had two major advantages he didn't have in 1912: incumbency, and the backing of one of the two major parties.
When McKinley was assassinated, Roosevelt was his vice president, and so took over the presidency without having to be elected. This meant in 1904 he was running as an incumbent, and the nominee of the Republican Party. When his second term ended, he endorsed Taft as his successor.
In 1912, Roosevelt no longer saw eye to eye with Taft, and ran a third party campaign against him. Taft and Roosevelt represented different wings of the Republican party, and so in an election where 60% of the vote went to a Republican or former Republican candidate, neither candidate alone could beat Wilson's 40%.