maybe this is a very stupid question and I'm missing something very trivial.
It's well known that $U(1)$-bundles are classified by the Euler class or the first Chern class. More precisely, the isomorphism $$c: \check{H}^1 (X, \mathscr{C}^{\infty} (-, U(1))) \xrightarrow{\sim} H^2 (X, \mathbb{Z})$$, induced by the exact sequence $0 \rightarrow \mathbb{Z} \rightarrow \mathbb{R} \xrightarrow{exp} U(1) \rightarrow 0$, the sheaf isomorphism $\mathscr{C}^{\infty} (-, \mathbb{Z}) \cong \mathbb{Z}_X$ and the isomorphism from \v{C}ech to singular cohomology (or de Rham cohomology with integral periods), is the first Chern class or the Euler class.
It's well known too that the first Chern class is given by $$[\frac{1}{2\pi i}F_{\nabla}]$$. This equality can be accomplished by using that the first Chern class is equal to the Euler class, the global angular form $\psi$ restricts to the Maurer-Cartan form on each fiber and every connection is of the form $\psi + \pi^{*} \alpha$ for some $\alpha \in \Omega^1 (X, \mathfrak{u}(1))$, where $\pi: P \twoheadrightarrow X$ is the $U(1)$-bundle
1) From these two remarks, one can conclude that if $F_{\nabla} = 0$ on some circle bundle $P$, then $c_1 (P) = 0$ and, therefore, $P$ is trivial.
However it's well known too that in the theory of Cheeger-Simons differential characters $$H^1 (X, U(1))$$ classifies flat $U(1)$-bundles with connection by assigning the holonomy $$\text{Hol}_{\nabla} (z) = \langle c, z \rangle$$ for every $z \in Z^1 (X, \mathbb{Z})$ to each $[c] \in H^1 (X, U(1))$ and using the canonical pairing coming from the fact that $U (1)$ is divisible and, hence, $H^1 (X, U(1)) = \text{Hom} (H_1 (X, \mathbb{Z}), U(1))$.
2) Therefore it may exist non-trivial bundles with flat connection whenever the first cohomology does not vanish.
Having this in mind, why there's a non-trivial flat $U(1)$-bundle?
In other words, what's wrong in my conclusions in 1 and 2?
Thanks in advance.
The Euler class detects topological triviality, not triviality in the finer sense of whether or not a flat connection is a product.
The prototypical example of a flat, non-trivial bundle starts with the product bundle $[0, 1] \times U(1) \to [0, 1]$ equipped with the product connection. If $\theta$ is an arbitrary real number, glue the fibre over $0$ to the fibre over $1$ by rotating through $\theta$; that is, identify $(0, e^{i\phi}) \sim (1, e^{i(\phi + \theta)})$.
The result is a flat, topologically-trivial $U(1)$ bundle $P \to S^{1}$ over the circle. If $\theta \not\in 2\pi \mathbf{Z}$, however, then $P$ admits no covariantly-constant section. When an arbitrary point of $S^{1}$ is removed, the restriction of $P$ to the resulting open interval $I$ is a product bundle $I \times U(1)$ whose covariantly-constant sections are constant maps $I \to U(1)$, and no such section extends continously to a global section of $P$.
In case it's of interest, there similarly exist topologically-trivial holomorphic line bundles over an elliptic curve $E$ that admit no non-trivial global section. For example, let $p$ and $q$ be distinct points of $E$, and let $L$ be the line bundle associated to the divisor $[p] - [q]$. A non-trivial holomorphic section of $L$ would define a meromorphic function $f$ on $E$, holomorphic off $q$ and with a simple zero at $p$ and a simple pole at $q$. Integrating the meromorphic $1$-form $$ \eta = z \frac{f'(z)\, dz}{f(z)} $$ around the boundary of a fundamental domain for $E$ and using the fact that the total residue is zero would give $p - q = 0$, which is not the case.