I have an exercise in my textbook:
The first one I try to prove by contrapositive:
Suppose $f$ is not bounded. Then $\forall M \in \Bbb R : |f(x)| \gt M \text{ },\forall x \in X$
$\Rightarrow f(x) \gt M $ or $f(x) \lt -M$
Hence $\forall \epsilon \text{ }\exists \delta \leq |b-a| : |x-y| \lt \delta$ but $|f(x)-f(y)| \gt \epsilon$ since
$$|f(x)| \gt M \Leftrightarrow f(x) \gt M \text{ or } f(x) \lt -M$$
$\Rightarrow f(x) \gt \epsilon + f(y) \text{ or } f(x) \lt -\epsilon-f(y)$
$\Leftrightarrow |f(x) -f(y)| \gt \epsilon$
Hence, by definition, $f$ is not uniformly continuous.
I think I'm doing something wrong since in the following task I observe that the function $g(x) =x$, $\Bbb R\rightarrow \Bbb R$ is not bounded but it is uniformly continuous.
(also, $g(x)= \text{sin}(x)$ is uniformly continuous, right?)

First of all, I think you need to brush up on negations.
Bounded: There exists $M>0$ such that $|f(x)|\leq M$ for all $x \in (a,b)$.
Negation: For all $M>0$, there exists $x\in(a,b)$ such that $|f(x)|>M$.
Uniformly continuous: For all $\epsilon>0$, there exists $\delta>0$ such that for all $x,y$ with $|x-y|<\delta$, we have $|f(x)-f(y)|<\epsilon$.
Negation: There exists $\epsilon>0$ such that for all $\delta>0$, there exists $x,y$ with $|x-y|<\delta$, but $|f(x)-f(y)|\geq \epsilon$.
In this problem, I don't see much value from using a proof by contradiction. For the direct proof, here are some hints. (Uniformly) continuous functions are bounded on closed intervals. Therefore, for any small $\delta>0$, we have $f$ is bounded on $[a+\delta,b-\delta]$.
Let $\epsilon>0$ be fixed. Then there exists $\delta>0$ such that for all $x,y\in(a,b)$ with $|x-y|<\delta$, we have $|f(x)-f(y)|<\epsilon$. Consider the interval $(a,a+\delta]$. Restrict $\delta$ so that $(a,a+\delta]\subset (a,b)$ and $[b-\delta,b)\subset (a,b)$. Fix $y\in (a,a+\delta]$. Then what can you say about $f(x)$ for all $x \in (a,a+\delta]$? Apply a similar argument on $[b-\delta,b)$. You will get three bounds, on the intervals $(a,a+\delta],\, [a+\delta,b-\delta],\, [b-\delta,b)$ respectively.