Why did the United States think it was important to build a canal cross Central America?
The US needed to make the journey by ship between the east coast and the west coast shorter, both for commercial and military purposes.
Once the US had reached its goal of controlling the continent from coast to coast, business and trade interests convinced the government that the expansion should continue across the Pacific Ocean and into Asia. That meant the US needed to become a major naval power to be able to protect its business interests not just in the Atlantic and Caribbean, but also in the Pacific. The trip around South America just took too long.
As early as the 1840s, the US was involved in a dispute with Great Britain over controlling the most likely route of a trans-ocean canal across Central America -- which at that time went across Nicaragua, where a large lake would have cut down on the amount of actual digging that a canal would require.
Although the US eventually eliminated British competition for that path, it was the French who raised the funds and began the process of digging a canal across the narrow Isthmus of Panama at the end of the 19th century.
The French company controlling that project eventually went bankrupt, and the US moved quickly to take over the project and complete it.