Let us review the definition of log, as shown on Wikipedia, slightly edited.
In mathematics, the logarithm is the inverse function to exponentiation. That means the logarithm of a given number $x$ is the exponent to which another fixed number, the base $b$, must be raised, to produce that number $x$.
More explicitly, the defining relation between exponentiation and logarithm is
$\quad\log _{b}(x)=y$ exactly if and only if $b^{y}=x$.
For example, $log_2 64 = 6$, as $64 = 2^6$.
Let us take a look at the deductions in the question.
\begin{align*}
&P=2^{\log_2 N}\\
&\Rightarrow \log_2 P = \log_2 N &\text {// the first implication}\\
&\Rightarrow P=N &\text {// the second implication}\\
&\Rightarrow 2^{\log_2 N}=N\,. &\text {// the third implication}\\
\end{align*}
If you replace $b$ by 2, $y$ by $\log_2N$, and $x$ by $P$ in the definition, you have obtained the first implication. You can also say, since the result of raising 2 to the exponent $\log_2N$ is $P$, then by definition, that exponent, $\log_2N$ is $\log_2P$.
Now look at the second equality. You can raise 2 to the power of the left hand side, obtaining $P$ by definition. You can also raise 2 to the power of the right hand side, obtaining $N$ by definition. So $P=N$, which is the second implication.
In fact, you can go directly from the first equality to the third equality by definition directly. Since $\log_2 N$ is the exponent to which 2 must be raised to produce $N$, i.e., $2^{(\log_2N)}=N$, so $P=N$.
Well, I cannot say the third implication is wrong in the sense that you can never say it is wrong that "2=2" implies "3=3" since both of them are correct.
Instead, I will say the last equality is the very definition of logarithm. If you raise 2 to the power of some number and you get $N$, then that (unique) number is (defined as) $\log_2N$.
The most powerful, most basic, most natural and most correct way in mathematics is (using) definitions. People sometimes forget about what or where are the definitions. Instead they might resort to some kind of intuition, which might be helpful and important in various ways. However, the definitions will always be the most fundamental piece that one should be become familiar. For myself, I believe I should have read most if not every definition in math that I am supposed to read at least 10 times. Your mileage may vary a lot, of course.
By the way, here is the more complete definition/explanation of logarithm.
In mathematics, the logarithm is the inverse function to exponentiation. That means the logarithm of a given number $x$ is the exponent to which another fixed number, the base $b$, must be raised, to produce that number $x$. In the simplest case the logarithm counts repeated multiplication of the same factor; e.g., since 1000 = 10 × 10 × 10 = 103, the "logarithm to base 10" of 1000 is 3. The logarithm of $x$ to base $b$ is denoted as $log_b (x)$ (or, without parentheses, as $\log_b x$, or even without explicit base as $\log x$, when no confusion is possible). More generally, exponentiation allows any positive real number to be raised to any real power, always producing a positive result, so the logarithm for any two positive real numbers $b$ and $x$ where $b$ is not equal to 1, is always a unique real number y. More explicitly, the defining relation between exponentiation and logarithm is:
$\quad\log _{b}(x)=y$ exactly if $b^{y}=x$.
For example, $log_2 64 = 6$, as $64 = 2^6$.
Please note that, there is a fundamental piece that is not include in that part of Wikipedia entry. That is, why can we define the inverse function of exponentiation? Recall that not all functions can have inverse functions. That question is addressed later at https://en.wikipedia.org/wiki/Logarithm#Logarithmic_function. From logic point of view, we should first prove that exponentiation with some base is strictly decreasing when the base is smaller than 1 and strictly increasing when the base is greater than 1. Then we can define its inverse, logarithm with respect to that base.