What could he have done?
I can’t, of course, claim that Buchanan, or someone else, would have succeeded in averting the Civil War had they done some particular thing. Buchanan’s failure was in projecting a whole texture of administrative weakness and trying to be neutral on slavery issues, doing nothing to push back against the secessionists. By contrast, Jackson quashed the Secession Crisis of the 1830’s (at least two decades) by taking a strong executive hand.
Buchanan asserted the opposite of Federal executive power in this regard. He went along with the Dred Scott decision (which let the Federal Government “do nothing”). He held that the States could do anything they wished about “their” domestic arrangements, and that the Federal Government was essentially powerless.
Buchanan had been out of the country as a diplomat during much of the key wrangling over slavery in Congress, and perhaps did not grasp the intensity and danger posed to the Union. He supposedly did want to offend his Southern friends and supporters. The upshot of weakness and inaction was that pressure built up without resolution, and pushed politics to more radical extremes. At the 1860 Democratic convention, he derailed Douglas’ campaign to be the sole nominee who would take on Abraham Lincoln, leaving the Democrats split between two nominees (Douglas and John Breckinridge), almost ensuring Lincoln’s election. Splitting the Democrat Party was a key part of the radical Secessionists strategy to sever the South from the Union. I doubt Buchanan helped this along deliberately, but he played into their hands.