There were many reasons to build through Panama instead of Nicaragua:
1) Panama is reasonably much more smaller (See attached Pictures 1 & 2)
1.5) Smaller meant less work (effectively, but doesn't mean no work at all), as well as less time & money spent on the project
2) Panama was freed from Colombia rule with the help of the U.S., and so the rights to building the canal was awarded to the US.
~