Some spells affect an area. Sometimes a spell description specifies a specially defined area, but usually an area falls into one of the categories defined below.
Regardless of the shape of the area, you select the point where the spell originates, but otherwise you don't control which creatures or objects the spell affects. The point of origin of a spell is always a grid intersection. When determining whether a given creature is within the area of a spell, count out the distance from the point of origin in squares just as you do when moving a character or when determining the range for a ranged attack. The only difference is that instead of counting from the center of one square to the center of the next, you count from intersection to intersection.
You can count diagonally across a square, but remember that every second diagonal counts as 2 squares of distance. If the far edge of a square is within the spell's area, anything within that square is within the spell's area. If the spell's area only touches the near edge of a square, however, anything within that square is unaffected by the spell.
See Aiming a Spell for full details.
Are spell and other area of effects 2d (as in, they affect a flat grid only) or are they 3d (as in, they affect cubes and spheres)?
Just because things are normally expressed on a flat grid doesn't mean they're actually flat. Any effect with a radius affects a sphere, not a circle. A cone is a 3d area. A line is a line, not a plane.
[Source]