Given a prime number $\,p\gt2\,$ and a positive integer $\,n\gt1$, let's define the function $$f_n(p)=1+(p-1)^n$$ Of course, if $\,n\,$ is odd the function is divisible by $\,p\,$, while if $\,n\,$ is even the function can produce a prime number. Experimental evidence suggests that this only happens for even values of $\,n\,$ which are powers of $\,2$, that is $\,n=2^k\,$ for some $\,k$.
If we graphically represent the minimum even values of $\,n\,$ for prime numbers up to $\,10^3$, we obtain (in X axis you find the index $\,i\,$ of the $\,i$-th prime, while in Y axis are represented the values of $\,n$):
I ask how the validity of the previous assertion can be demonstrated, that is:
the only values of $\,n\gt1\,$ which can generate prime numbers of the form $\,1+(p-1)^n\,$ with $\,p\gt2\,$ prime, are those of the form $\,2^k\,$ for some $\,k$.
Many thanks.

Your assertion is true. Assume that $n$ is not a power of $2$, so it has some odd factor $d \gt 1$ such that $n = 2^k(d)$. Then you would get
$$1 + (p-1)^{2^k(d)} = 1^d + \left((p-1)^{2^k}\right)^{d} \tag{1}\label{eq1A}$$
However, for odd $d$, note you can use factoring to get
$$\begin{equation}\begin{aligned} x^d + y^d & = (x + y)\left(\sum_{i=0}^{d - 1}(-1)^i x^{d - (i + 1)}y^{i}\right) \\ & = (x + y)(x^{d-1} - x^{d-2}y + \ldots - xy^{d-2} + y^{d-1}) \end{aligned}\end{equation}\tag{2}\label{eq2A}$$
Thus, as you can see, with $x = 1$ and $y = (p - 1)^{2^k}$ in \eqref{eq2A}, you have that \eqref{eq1A} has a factor of $1 + (p - 1)^{2^k}$ in it times an integer $\gt 1$, so it can't be prime.
FYI, it's this basic factoring reason which is why the only values of $n$ where $2^n + 1$ could possibly be prime is when $n$ is a power of $2$. Note the numbers of this form are called Fermat numbers, with the only $5$ currently known actual primes among that group being called Fermat primes.