Understanding the Ampere's Law We want to study the magnetic field at point $P$. So, from the figure we take that:



*

*$\oint_{L_1} B\cdot dl=\mu_0 I_1$

*$\oint_{L_2} B\cdot dl=\mu_0 I_2$

*$\oint_{L_3} B\cdot dl=\mu_0 I_2$


The magnetic field contribution of the current $i_1$ at the point $P$ is: $B_1=\frac{\mu_0I_1}{2\pi r}$. And the magnetic field contribution of the current $i_2$ at the point $P$ is: $B_2=\frac{\mu_0I_2}{2\pi r}$. Then, the resulting magnetic field at point $P$ is: $$B = \frac{\mu_0(I_1+I_2)}{2\pi r}$$
But, my question is what happen if I take into account the line $L_3$? Because it also has a contribution $B_3=\frac{\mu_0I_2}{2\pi r}$ at point $P$. Would be erroneous to say that $B = B_1+B_2+B_3$. 
Does the problem is that $L_3$ is in the same current that the $L_1$ line? If it is so, what happen if $i_1=i_2$ and both wires are in the same circuit? would it be wrong to separately calculate contributions from $L_1$ and $L_2$?
I'm a little confused about it.
 A: Explanation 1: Using Amperes law
Amperes law says that 
$\oint_{A} \mathbf{B}\cdot \mathbf{dl}=\mu_0 I$.
In the special case, when you know beforehand, that at every point of the edge of area $A$


*

*$\left|\mathbf{B}\right| = B$ is constant and

*$\mathbf{B}$ perpendicular to $\mathbf{dl}$, so that $\mathbf{B}\cdot \mathbf{dl} = Bdl \sin90^\circ = Bdl$ 


Then you can take the $B$ out of the integral:
$B\underbrace{\oint_{A} dl}_{= \ell} =\mu_0 I$.
If the length $\ell$ is circle with radius $r$, $\ell = 2 \pi r$, then the field will be:
$B = \frac{\mu_0 I }{2 \pi r}$.
In this particular case:


*

*You assume that the wires are infinite (if not, you have to use Biot-Savart, see below)

*Because the wires are infinite, then you can use the equation $B = \frac{\mu_0 I }{2 \pi r}$ for both wires


*

*For wires 1 and 2 the magnetic field at distance $r$ is $\frac{\mu_0 i_x}{2 \pi r}$, and because they are in the same direction, the resulting field in the middle of the wires is 



$ B_{\mathrm{tot}} = \frac{\mu_0 (i_1 + i_2)}{2 \pi r}$
It does not matter if in the picture there is drawn 2,3 or 85 circles going trough the point P. Only the wires having current affect to the magnetic field (not imaginary lines).

Explanation 2: Using the law of Biot and Savart
The equation 
$B = \frac{\mu_0 I}{2 \pi r}$ holds for the magnetic field of an infinite wire having current $I$ going trough it. It is also an approximation used for very long wires, or then the point distance $r$ is much smaller than the length of the wire.
It is originally derived using the law of Biot and Savart, which says that 
$\ \mathbf{B} = \frac{\mu_0}{4\pi} \int\frac{I \mathbf{dl} \times\hat{r}}{r^2}$.
where
$\mathbf{dl_i}$ is the differential of the wire, which is a infinitesimal vector to the direction of the wire at the point.
$\hat{r}$ is the unit vector pointing from the point at wire $i$ to P.
$r$ is the distance from the point at the wire to P. 
and it already has included all the points of the wire to the field $B$. That's why you cannot add the effect of the point of the wire inside circle $L_3$ again.
A: $B = B_1 + B_2 + B_3$ wouldn't make sense because you're double counting the magnetic field due to $i_2$.  Also, you're not calculating $B_3$ correctly.  The left-hand side of Ampere's law is only equal to $B(2\pi R)$ if the magnetic field has the same magnitude at all points of circle, and the magnetic field is parallel to $\vec{dl}$ at all points on the circle.  But the second condition does't hold for loop 3, so you have to take into account the angle between the magnetic field and $\vec{dl}$ when evaluating the dot product.
A: The other answers are correct in pointing out that due to your choice of loop you cannot factor $\vec B_3$ out of its integral (because its dot product with $d\vec l$ depends on where you are on the loop). However, the reason that the magnetic field at $P$ is given by $\vec B_1 + \vec B_2$ is because of the symmetry of the problem. 
These infinite wires each independently produce $\vec B$-fields that do not depend on where you are along the length of the wire or at what angle (between $0$ and $2\pi$) you are at around the axis of the wire. This must be so by a simple inspection of the translational and rotational invariance of reference frames for this system. As a result, the only parameter for calculating the magnetic field of one of the wires that you need is its radial distance from the wire ($r$).
This is the key point: Amepere's Law is only useful for calculating the magnetic field of systems that have enough symmetry (usually, cylindrical symmetry).
The field at $P$ is given by $\vec B_1+\vec B_2$ because you know the direction of the vector field by analyzing the symmetry of the system, which (in turn) allows you to use Ampere's Law to calculate the field's strength. And summing the fields of the two wires independently is only doable because the fields are linear.
As noted above, every differential piece of the current does contribute to the field (and the details of that can be calculated with the Biot-Savart Law), but by a happy coincidence of the symmetries of this particular problem, Ampere's Law allows us to calculate the answer much more easily.
