Why do I get two results from a single free body diagram? Calculating the component of the normal force (anti-)parallel to the gravitational force and setting them equal, I get
\begin{equation}
  N \cos \theta = m\, g.
\end{equation}
On the other hand, calculating the component of the gravitational force (anti-)parallel to the normal force and setting them equal, I get
\begin{equation}
  m\, g\, \cos \theta = N.
\end{equation}
Where have I gone wrong?

It's being assumed as a duplicate of an already answered question which I think is more about specifics. It addresses two separate diagrams with two situations whereas mine is more general and has different situation than the one in the question. It's like we look alike but fingerprints are different and fingerprints are what matter.
 A: For any given case there are some obvious details that must not be contradicted. A FBD provides a more mathematical approach towards the question but how we form our equations is based on these critical details. 
A correct FBD satisfies all these details (or observations).   
For the given case, the observations are:


*

*The wedge is stationary,

*The block never looses contact with the wedge, and

*The block accelerates along the wedge.


When you resolve the normal force vertically and horizontally, you come to two conclusions.
Conclusion $(1)$, Vertical Equilibrium.
$N\cos{\theta}=mg$ 
This equation indicates that the block is in vertical equilibrium, but this contradicts with observation $(3)$. The block must move vertically downwards.

Conclusion (2), Horizontal acceleration.
$ma=N\sin{\theta}$ 
In this case, we know that the block never leaves the wedge but if the block has some net horizontal acceleration (as shown in the diagram), it will definitely leave the wedge. This contradicts observation $(2)$.
So, the equations that we come up with using this FBD must be wrong because they don't satisfy our observations. However, it does not mean that the FBD is wrong but the equations we come up with the FBD are wrong.
$$N\cos{\theta} \neq mg$$
When you resolve the weight of the block along and perpendicular the wedge, the resultant FBD satisfies all our observations. The two correct equations are,
Perpendicular to the surface: Equation (1), $mg\cos{\theta}=N$, this satisfies observation $(2)$.
Along the surface: Equation (2),$ma=mg\sin{\theta}$, this satisfies observation $(2)$ and $(3)$.
These equations in combined sense, tell us that the net force on the block is $mg\sin{\theta}$. The normal force has cancelled out $mg\cos{\theta}$.
Therefore, this is the correct FBD.
Moreover, we also know this by observation that the block will move both forward and downward. So, if you further resolve $mg\sin{\theta}$ vertically and horizontally, you will get the true vertical and horizontal acceleration of the block respectively. 
However, if the wedge is accelerating too, you just have to form equations that satisfy the observations. The most important observation in either of the cases is the block is stationary with respect to the wedge's surface.
I hope forming correct equations wouldn't be a problem for you anymore. 
A: Some context is needed.  The answer depends on the acceleration.


*

*Frictionless ramp: in this case, the block accelerates down the ramp.  There is no acceleration in a direction normal to the ramp, so there is no net force in that direction, so $N=mg \mathrm{cos}\theta$.

*Banked turn: in this case, the acceleration is horizontal, so there is no net vertical force. Thus $N\mathrm{cos}\theta=mg$.
A: The physical principle behind problems like this is Newtons first law:
$F=M*a$
Where F is the sum of all forces in a direction. 
In most school problems, there is no motion( and thus acceleration) in the considered direction, and the equation reduces to $F=0$. Unfortunately many people jump to the conclusion that $F=0$ without motivating it. Many times they are lucky and there is indeed no motion in that direction, and they get the right answer. But sometimes the assumption that there is no acceleration is wrong. In that case they get the wrong answer, and may not be able to figure out why. This is a perfect example of a situation like that. Without friction, which is the case according to the FBD drawn, the block will accelerate down the slope. A component of this acceleration is in the vertical direction, thus the assumption that the sum of forces in the vertical direction is zero is incorrect. This results in a wrong answer. 
It has been suggested in other answers that the FBD is incorrect and should be solved in certain directions. This is not true. The problem can be solved by decomposing the forces in any two directions, as long as they are not on the same line. The proof below shows that the problem can be solved by decomposing the forces along and perpendicular to the slope, but also in horizontal and vertical direction. 
Let's start with the easy solution, and derive the equations of motion in the direction of the slope and perpendicular to it. I'll define the t direction as going down the slope, and the n direction perpendicular to it downward. The equations are:  

$$\begin{align}
mg\sin\theta &= ma_{t} \tag{1a} \\
mg\cos\theta - N &= ma_{n} \tag{2a}
\end{align}$$ 

Now we should note that N is not a random force, but it is the reaction force that keeps the block on the slope. Therefore the acceleration perpendicular to the slope is zero, and we will call the acceleration along the slope a. The equations now reduce to: 

$$\begin{align}
mg\sin\theta &= ma \tag{3a} \\
mg\cos\theta - N & = 0 \tag{4a}
\end{align}$$ 

Or:  

$$\begin{align}
ma &= mg\sin\theta \tag{5a} \\
N &= mg\cos\theta \tag{6a}
\end{align}$$ 

Now the difficult part, solving the system in horizontal and vertical direction. We will define the x direction as to the left, and the y direction downward. We then get the following equations:  

$$\begin{align}
mg - N\cos\theta &= ma_{y} \tag{1b} \\
N\sin\theta &= ma_{x} \tag{2b}
\end{align}$$ 

Again we know that the block can only move along the slope, because N is a reaction force, and again we call the acceleration along the slope (downward) a. So we get the following equations:  

$$\begin{align}
mg - N\cos\theta &= ma\sin\theta \tag{3b} \\
N\sin\theta &= ma\cos\theta \tag{4b}
\end{align}$$ 

Equation 4b can now be rewritten as:

$$\begin{align}
N &= \frac{ma\cos\theta}{sin\theta} \tag{5b}
\end{align}$$ 

Now equation 5b can be inserted in 3b:  

$$\begin{align}
mg - ma \frac{cos\theta}{sin\theta} cos\theta &= ma\sin\theta \tag{6b} 
\end{align}$$ 

This can be rearranged to:  

$$\begin{align}
mg &= ma \big( \frac{cos\theta}{sin\theta} cos\theta + sin\theta \big) \tag{7b} 
\end{align}$$ 

Now we multiply the second term in the brackets with $\frac{sin\theta}{sin\theta}$ and get:  

$$\begin{align}
mg &= ma \big( \frac{1}{sin\theta} \big) \tag{8b} 
\end{align}$$ 

Or:  

$$\begin{align}
ma &= mg\sin\theta \tag{9b} 
\end{align}$$ 

This is the same as equation 5a. Inserting this in equation 5b gives:  

$$\begin{align}
N &= mg\sin\theta \frac{cos\theta}{sin\theta} \tag{10b}
\end{align}$$ 

This simplifies to:  

$$\begin{align}
N &= mg\cos\theta \tag{11b}
\end{align}$$ 

Which is again the same as 6a.  
The important lesson to be learned here is to always write down the accelerations explicitly, and only to set them to zero after you prove they will be zero.
A: you should not resolve the normal into components 
This is because Ncosθ≠mg. There is non-zero acceleration in the downward direction.if the block is in equilibrium there is some other force pushing the block along the inclined plane. 
the force acting along the inclined plane which is pushing the body up can be resolved into components
1.the normal force is due to contact between the body and the plane 
2.the mg(downward force) is due to gravity 
the force which is not normal to the surface is resolved 
A: You have made a mistake in applying newton's 2nd law here. It says that $\sum \vec{F}=m\vec{a}$.
Since the body accelerates along the slope of the ramp (say, with acceleration $a$) there will be a component of acceleration $a\sin{\theta}$ which is along the vertical. So newton's 2nd law, when applied in the vertical direction becomes:
$$mg-N\cos{\theta} = ma\sin{\theta}$$
Suppose instead, we apply newton's 2nd law along the direction of the normal reaction, then the component of acceleration along the normal is $a\cos{90^{\circ}} = 0$. So newton's 2nd law becomes:
$$N - mg\cos{\theta}=ma\cos{90^{\circ}}=0$$
$$\Longrightarrow N=mg\cos{\theta}$$

Now, you can use both the FBD's to solve the problem, theres nothing wrong with that. Each free body diagram gives you 2 equations (along the 2 perpendicular directions), which you need to solve the 2 variables in the problem, $N$ and $a$. 
Normally, people use the first free body diagram, because then you don't have to solve the equations instead you directly can solve for the variables (as you have done)
A: Before summing forces as described in the other answers, I find it helpful to add a little more detail to the FBD. Here, it's easy to see that N = mg cos(theta) instead of mg = N cos(theta)

Here's a FBD for a banked road, with centripetal force shown.

A: You made a very simple trigonometric mistake. 
When you equated $N=mg \cdot cos(\theta)$ its wrong. Look up $cos(\theta)$ definition and you will understand. 

cosine:
noun, Mathematics
the trigonometric function that is equal to the ratio of the side adjacent to an acute angle (in a right-angled triangle) to the hypotenuse.

Based on this, the relation has to be, in the right top diagram, as $N=\frac{mg}{cos(\theta)}$
And indeed, you arrive at the same relation in your second diagram.

REMEMBER : Number never lie; if they appear to, then it must be our mistake :P

A: You are splitting the forces correctly. But why are you setting them equal?
You do that because you assume Newton's 1st law. The problem is just that Newton's 1st law doesn't apply in both cases. It only applies in the direction perpendicular to the surface, since nothing accelerates in that direction. So, your second equation is correct.
In any other direction, there is an acceleration component included, so you must use Newton's 2nd law and include a mass-times-acceleration-component term. The first equation is wrong and should have been:
$$N\cos(\theta)=mg-ma\sin(\theta)$$
