Sometime faces have vertices that not aligned in one plane. For example if I have this (face should be flat here):
It rather should be like that:
Blender Stack Exchange is a question and answer site for people who use Blender to create 3D graphics, animations, or games. It only takes a minute to sign up.Sign up to join this community
Couple of ways you could do this:
If you want to make it flat horizontally set the 3D cursor as a pivot point, select the vertex which is lying on a grid floor and snap the cursor to it (Shift+S-->Cursor to Selected) .Then select the non aligned one and press S,Z,0.
If you want do it like in your second picture duplicate the non alligned edge in Edit Mode and snap it to the opposite part of a plane (click the magnet icon, snap element type- Vertex), then merge the vertices as pictured below (Alt+M-->At Last). Finally select the whole mesh and remove doubles (W-->Remove Doubles).