Both the proofs are the same. This is an example of a proof by transposition or proof by contrapositive where you prove the contrapositive.
The statement $A \Rightarrow B$ is equivalent to the statement $\neg B \Rightarrow \neg A$.
Hence, proving $A \Rightarrow B$ is equivalent to proving $\neg B \Rightarrow \neg A$.
The statement $A$ in your problem is "$2^n - 1$ is a prime" and the statement $B$ in your problem is "$n$ is a prime".
In this context, we have "If $2^n - 1$ is a prime, then $n$ is a prime".
The contrapositive is "If $n$ is not a prime then $2^n - 1$ is not a prime".
The author now proves the contrapositive statement. Hence, the author takes $n$ to be not a prime i.e. he takes $n$ to be a composite number.
Since $n$ is a composite number, $n$ can be written as $n = kl$, where $2 \leq k,l < n$.
So $2^n - 1 = 2^{kl} - 1 = (2^k)^l-1$.
Now observe that $(a-1)|(a^l - 1)$, $\forall l \in \mathbb{N}$.
This can be seen from the remainder theorem or by factorizing $(a^l - 1) = (a-1) (a^{l-1} + a^{l-2} + \cdots + a + 1)$.
Note that $2 < 2^k-1 < 2^n-1$ since $2 \leq k<n$ and plug in $a=2^k$, we get $((2^k)^l - 1) = ((2^k)-1) ((2^k)^{l-1} + (2^k)^{l-2} + \cdots + (2^k) + 1)$. Hence, we have $(2^k - 1)|(2^n-1)$, which implies $2^n-1$ is a composite number.
Hence, we have "If $n$ is not a prime then $2^n - 1$ is not a prime" which implies the contrapositive i.e. "If $2^n - 1$ is a prime, then $n$ is a prime".
Note
Say, we denote the original statement by $A$.
Let $A$ be the statement "If $2^n - 1$ is a prime, then $n$ is a prime"
Let $B$ be the statement "If $n$ is not a prime, then $2^n-1$ is not a prime"
Let $C$ be the statement "If $2^n-1$ is not a prime, then $n$ is not a prime"
Let $D$ be the statement "If $n$ is a prime, then $2^n - 1$ is a prime"
Statements $A$ and $B$ are contrapositives of each other. So if $A$ is true then so is $B$ and if $B$ is true then so is $A$.
Similarly, Statements $C$ and $D$ are contrapositives of each other. So if $C$ is true then so is $D$ and if $D$ is true then so is $C$.
Statements $C$(equivalently statement $D$) and $A$(equivalently statement $B$) are converses of each other. In general, we cannot conclude that if a statement is true then its converse is true and we cannot conclude that if a converse is true then the statement is true.
In this example, statement $A$(equivalently statement $B$) is true.
However, statements $C$(equivalently statement $D$) which is the converse of statement $A$(equivalently statement $B$) is false.
An example is $2^{11} - 1 = 2047 = 23 × 89$ is not a prime but $11$ is a prime. So $C$(equivalently statement $D$) is false.