It's not difficult to see that
$$X_t := \exp \left(\sqrt{2} B_t \right)$$
solves the given SDE. (You can either use Itô's formula to check it or use some standard methods for linear SDE's to obtain this solution.) Moreover, by Ito's formula:
$$f(t,X_t)-\underbrace{f(0,x_0)}_{x_0} = \sqrt{2} \int_0^t e^{-s} \cdot X_s \, dB_s + \int_0^t e^{-s} \cdot X_s + (-e^{-s} \cdot X_s) \, ds \\ = \sqrt{2} \int_0^t e^{-s} \cdot e^{\sqrt{2} B_s} \,dB_s \\ \Rightarrow f(t,X_t) = \underbrace{\sqrt{2} \int_0^t e^{\sqrt{2} B_s-s} \,dB_s}_{M_t} + \underbrace{x_0}_{A_t}$$
where $x_0=1$. Let
$$g(s,w) := \sqrt{2} \cdot e^{\sqrt{2} B(s,w)-s}$$
Then $g \in L^2(\lambda_T \otimes \mathbb{P})$, i.e.
$$\int_0^T \int_\Omega g(s,w)^2 \, d\mathbb{P} \, ds <\infty$$
There is a general result which says that this condition implies that $M_t$ is a martingale (and not only a local one). Moreover,
$$\langle M,M \rangle_t = \int_0^t |g(s,w)|^2 \, ds$$
(see René L. Schilling/Lothar Partzsch: "Brownian Motion - An Introduction to stochastic processes", Theorem 14.13).
Concerning the integral $\mathbb{E}(e^{-\tau} \cdot X_\tau)$: Remark that
$$\tau = \inf\{t \geq 0; X_t=2-t\} = \inf\{t \geq 0; \sqrt{2} B_t = \ln(2-t)\}$$
Now let
$$\sigma := 2\tau = \inf\{t \geq 0; \underbrace{\sqrt{2} B_{\frac{t}{2}}}_{=:W_t} = \ln (2-t/2)\}$$
where $(W_t)_{t \geq 0}$ is again a Brownian Motion (scaling property). Thus
$$\mathbb{E}(e^{-\tau} \cdot X_\tau) = \mathbb{E}(e^{-\tau+\sqrt{2} B_\tau}) = \mathbb{E}(e^{-\frac{\sigma}{2}+W_\sigma}) \stackrel{\ast}{=} 1$$
In $(\ast)$ we applied the exponential Wald identity (see remark).
Remark Exponential Wald identity: Let $(W_t)_{t \geq 0}$ a Brownian motion and $\sigma$ a $\mathcal{F}_t^W$-stopping time such that $\mathbb{E}e^{\sigma/2}<\infty$, then $\mathbb{E}(e^{W_\sigma-\frac{\sigma}{2}})=1$. (see René L. Schilling/Lothar Partzsch: "Brownian Motion - An Introduction to stochastic processes", Theorem 5.14)
You cannot apply the formula
$$[G \bullet M]_t = \int_0^t G_s^2 \, d[M]_s \tag{1}$$
because the Ornstein-Uhlenbeck process $X$ is not of the form
$$X_t = (G \bullet B)_t,$$
but of the form $$X_t = (G_t \bullet B)_t$$ and -as your calculation show- we cannot expect that $(1)$ extends to this larger class of processes. The reason is, roughly, that $dt$-terms need a different compensation than $dB_t$-terms - and if you shift the multiplicative $dt$-term under the stochastic integral, then you pretend that it behaves, in some sense, like a $dB_t$-term ... but it doesn't.
The proper way is the following:
- Define $$Y_t := \int_0^t e^{\alpha s} \, dB_s.$$ Calculate $[Y]_t$ (that you can do using $(1)$.)
- Apply Itô's formula to find the stochastic differential $$d(X_t^2) = \sigma^2 d(e^{-2\alpha t} Y_t^2).$$
- The $dt$-term of the stochastic differential $d(X_t^2)$, obtained in step 2, equals the quadratic variation $[X]_t$.
Best Answer
The trouble is that there are two types of brackets, $\langle X \rangle_t$ (which I call angle bracket) and $[X]_t$ (sharp/square bracket). In this particular case they do not coincide because $(X_t)_{t \geq 0}$ is not a martingale (see also this answer).
These two characterizations are only equivalent if $(X_t)_{t \geq 0}$ is a martingale. For a semimartingale (with continuous sample paths) the sharp bracket $[X]_t$ is defined as
$$[X]_t := X_t^2-X_0^2 -2 \int_0^t X_s \, dX_s. \tag{1}$$
As long as $(X_t)_{t \geq 0}$ is not a martingale, we cannot expect that the process
$$X^2_t-[X]_t = X_0^2 + 2 \int_0^t X_s \, dX_s$$
is a martingale.
For your particular example, we obtain from Itô's formula that
$$X_t^2-X_0^2 = 2 \int_0^t X_s \, dX_s + \int_0^t X_s^2 \, ds,$$
so that, by $(1)$,
$$[X]_t = \int_0^t X_s^2 \, ds.$$ More generally, if $(X_t)_{t \geq 0}$ is an Itô process of the form
$$dX_t = b(t) \, dt + \sigma(t) \, dB_t,$$
then
$$[X]_t = \int_0^t \sigma^2(s) \, ds.$$