This is from an introduction to mathematical proofs a transition to advanced mathematics.
Let $g:\mathbb{N}\to A \cup \{x\}$ such that
$$g(n) = \begin{cases} x \ \ &\text{if} \ \ n=1\\ f(n-1) \ \ &\text{if} \ \ n\neq 1 \end{cases}$$ where $f:\mathbb{N}\to A$, where $A$ is denumerable or countably infinite and $f$ is a one-to-one correspondence or bijection.
Attempted proof - Suppose $n_1$ and $n_2$ are integers.
Case 1: If $n_1 = 1$ and $n_2 = 1$ then $$g(n_1) = g(n_2) \Leftrightarrow 1 = 1$$
Case 2: If $n_1\neq 1$ and $n_2\neq 1$ then
$$g(n_1) = g(n_2) \Leftrightarrow f(n_1 - 1) = f(n_2 - 1) \Leftrightarrow n_1 = n_2$$
Case 3: If $n_1 = 1$ and $n_2 \neq 1$ then
$$g(n_1) = g(n_2) \Rightarrow 1 = f(n_2 - 1)$$
What happens from there? I assume case 3 arrives at some contradiction but I am lost from here. Unless taking the inverse of both sides leads to $n_2 = 1$ which is a contradiction but I am not sure if that is true.
Also I am not sure how to prove that $g(n)$ is onto.
You need $f$ to be a bijection, as pointed out by @Gerry Myerson.
For surjectivity, you need that $\forall y\in A\cup\{x\}\,,\exists m\in\Bbb N$ such that $g(m)=y$.
If $y\in A\cup\{x\}$, then $y\in A$ or $y=x$.
If $y\in A$, then $g(m)=y$, where $m-1=f^{-1}(y)$.
And if $y=x$, then $g(1)=y$.
Thus $g$ is onto.