Why do Organolithium or Grignard reagents act as nucleophiles and not as bases with aldehydes and ketones I've read entire Chapter 14: Organometallic Compounds of  Francis Carey's "Organic Chemistry" but I still didn't get an answer to my question. 

Quote from the book:


  Because of their basicity organolithium compounds and Grignard reagents cannot be prepared or used in the presence of any material that bears a $\ce{-OH}$ hydroxyl group. Nor are these reagents compatible with $\ce{-NH}$ or $\ce{-SH}$ groups, which can also convert an organolithium or organomagnesium compound to a hydrocarbon by proton transfer.


Fine. No arguments with that. 


  Terminal alkynes also give alkanes with Organolithium and Organomagnesium compounds. 


Must be true if he says so. Now coming to the point,


  
  Ammonia and Amines have $\mathrm{p}K_\mathrm{a}$ around 36.
  Terminal alkynes have $\mathrm{p}K_\mathrm{a}$ of 25.
  Aldehyde $\mathrm{p}K_\mathrm{a} = 17$, Ketone $\mathrm{p}K_\mathrm{a} = 19$ and an Ester $\mathrm{p}K_\mathrm{a} = 25$.
  Water &amp; Alcohols have $\mathrm{p}K_\mathrm{a}$ of 15–18.
  


If organolithium compounds and Grignard reagents act like bases with alcohols, terminal alkynes, and amines/ammonia, why do they act like nucleophlies and give addition reaction with carbonyl compounds? Why don't they act as bases and give alkanes instead? What am I missing here?
In fact, both reagents you noted here have quite complex structure and are not nucleophiles at all: both are electrophiles, because metallic atom here has too little neighbors to draw electrons from.

Let me explain, using Grignard reagent $\ce{EtMgCl}$ . In reality it has complex structure with $\ce{Mg}$ atom coordinated to alkyl fragment and two diethyl ether molecules. When reacts, it coordinates first with most nucleophilic atom. In case of alcohol it is oxygen of $\ce{OH}$ fragment, and of course it  reacts with closest easily migrating atom: hydrogen, producing alkane. In case of ketone it coordinates with $\ce{CO}$ group, and alkyl group attacks closest electrophile : carbon from $\ce{CO}$ group, whose electrophility was just boosted.

If right compound, effectively bounding to metal atom, is added and no other way of reactions is readily available, both reagents can work as bases. For example, organolithium compounds can replace hydrogen atoms in alkynes, alkenes and arenes as you noted earlier.