Here is the question:
Let $f:A\to B $ and $g:B \to A$. Suppose $y=f(x)$ iff $x=g(y)$. Prove that $f$ is bijective and $g=f^{-1}$.
Here's my attempted proof:
Suppose $x_1,x_2 \in A$ and $f(x_1)=f(x_2)=y$ for some $y\in B$. Then $y=f(x_1)$ implies $x_1=g(y)$ and $y=f(x_2)$ implies $x_2=g(y)$. Thus, $x_1=x_2$ and we conclude that $f$ is injective.
Let $y \in B$. Then $g(y)=x$ for some $x \in A$. It follows that $y=f(x)$ for some $x\in A$. Hence, $f$ is surjective.
$f$ must be bijective since $f$ is injective and surjective. Also, it follows from the definition of inverse of a function that $g=f^{-1}$.
Is my proof valid?
Your proof is not clearly presented. It can be corrected with some 'quantification' fixes. It is helpful to look at $x$ and $y$ as free variables.
We are assuming that for every $x \in A$ and for every $y \in B$,
$\tag 1 y = f(x) \text{ iff } x = g(y)$.
$f$ is injective: If $x_1,x_2 \in A$ we can certainly write $y_1 = f(x_1)$ and $y_2 = f(x_2)$, or, equivalently, and $x_1 = g(y_1)$ and $x_2 = g(y_2)$. Now if $x_1 \ne x_2$ then $g(y_1) \ne g(y_2)$. Since $g$ is a function and can't have multiple outputs for a single input, both $y_1$ and $y_2$ must be distinct elements, i.e. $y_1 \ne y_2$.
We leave it to the OP to supply the surjectivity argument in a similar fashion (use consistent quantification clarity).
To show that $g$ is $f^{-1}$, you only need to show that $g$ is a left inverse since you have that $f$ is a bijection.
EXTRA STUFF
Using (1) is a way of showing bijectective correspondences by looking at relations in free variables.
Example: Consider the relation $y = \frac{1}{1-x}$ with $x \in [0,1)$. Solving for $x$,
$\quad y(1-x) = 1 \text{ iff}$
$\quad y-yx = 1 \text{ iff}$
$\quad x = \frac{y - 1}{y}$
So with $f(x) = \frac{1}{1-x}$ and $g(y) = \frac{y-1}{y}$ we are in the exact setting of (1) with $A = [0,1)$.
Show that $B = [1,+\infty)$.