Why do politicians choose mega projects in developing countries instead of spending more on health and education?
Advantages of a mega project:
It's easy to understand where the money is going.
It may return money locally, as a mega project may import from the funding country.
It may help a domestic business in a foreign country.
It may get the foreign country to support initiatives desired by the funding country.
I can't speaks as to other countries, but in the US, only $30 billion is spent on foreign aid. That compares to $150 billion on education (by the federal government) and more than a trillion on health care. Overall government spending on education is around a trillion and on health care is about $1.5 trillion. Figure another $400 billion and $1.7 trillion for private spending. Foreign aid would hardly make a rounding error in US spending on education and health care.
Since you've clarified your original question, I think I was answering the wrong thing. I was focusing on why the US might support foreign aid rather than domestic spending. The numbered points still apply. The problem with giving money to a small project in a country like Pakistan is that it is likely that not all the money would reach the intended recipients.
At least if you fund a big expensive hospital or school, you end up with the building. If you intend to fund teachers or doctors, you may end up funding bureaucrats instead. Then a newspaper does a story about how we are wasting our foreign aid on buying expensive dinners for bureaucrats. This then makes it harder to fund future foreign aid. So even though you are doubtless correct that more doctors, nurses, and teachers would provide more benefit, it is difficult for the US to supply that kind of aid.
There have been some classic misses in big project foreign aid. For example, a foreign built road helped some people in one country. Not the road itself, but the shoulders were cleared of vegetation and good for walking. Or the Saharan example of UN funded wells. They worked fine initially, but if the pumps broke, they couldn't be fixed with local resources. Then a religious organization (Mennonite) came in and showed them how to make an equivalent of the part that broke locally. And those are comparative successes of foreign aid.
Directing aid to small projects is even more difficult. People in developed countries understand roads and even wells. But they do not understand how to work within a foreign culture to increase education and health care resources. This activity may be better taken by more focused organizations. This may be improving. For example, microloan programs are something at which developed countries have had some success in funding. Or we may just not have learned about the corruption yet.