Why is ammonia #NH_3# pyramidal and not trigonal planar (flat)?
It is trigonal pyramidal because of the lone pair of electrons associated with the central nitrogen atom.
The Lewis structure for ammonia looks like this...
You can see the lone pair (nonbonding) of electrons directly above the nitrogen.
The nonbonding pair of electrons pushes away from the bonding pairs producing a trigonal pyramidal shape. If the central atom with no lone pair is bonded to three other atoms the molecule will have a trigonal planar shape.
This video reviews how to draw Lewis structures for molecules.
This video reviews how to determine the shape of molecules.
Hope this helps!