Suppose that $p\ne 0$. We assume without proof that the expectation exists. Note that $X$ is the number of trials until the first success. Let $a=E(X)$.
With probability $p$, we have success on the first trial. The expectation of $X$, given that we had success on the first trial, is $1$.
With probability $1-p$, we have a failure on the first trial. The expectation of $X$, given we had a failure on the first trial, is $1+a$. Thus
$$a=(p)(1)+(1-p)(1+a).$$
This is a linear equation in $a$. Solve.
Remark: Alternately, we have
$$E(X)=p\left(1+2q+3q^2+4q^3+5q^4+\cdots\right).$$
We calculate the sum $s$, where
$$s=1+2q+3q^2+4q^3+5q^4+\cdots.$$
Note that
$$sq=q+2q^2+3q^3+4q^4+\cdots.$$
Subtract. We get
$$s(1-q)=1+q+q^2+q^3+q^4+\cdots =\frac{1}{1-q}.$$
Thus $s=\frac{1}{(1-q)^2}=\frac{1}{p^2}$,
and therefore $E(X)=p\cdot \frac{1}{p^2}=\frac{1}{p}$.
We can modify this argument by looking at partial sums
$$1+2q+3q^2+\cdots +nq^n,$$
finding an explicit expression in basically the same way, and taking the limit as $n\to\infty$.