The hypotheses above are very strong, and they impose strong hypotheses on the cohomology of the complement $U$ of the universal hyperplane section. Using Leray spectral sequences for both projections, this quickly gives the result. Denote the dimension of $X$ by $n$, and denote by $m$ the dimension of the ambient projective space $\mathbb{CP}^m$ in which $X$ is embedded as a linearly nondegenerate variety.

**Proposition.** Assume that for every hyperplane $L$ in $\mathbb{CP}^m$, the intersection $H=L\cap X$ is a Cartier divisor in $X$ such that the open complement $X\setminus H$ is isomorphic to $\mathbb{C}^n$. Then $n$ equals $m$, and $X$ equals all of $\mathbb{CP}^m$.

**Proof.** Denote by $\widehat{\mathbb{CP}}^m$ the dual projective space of hyperplanes $L$ in $\mathbb{CP}^m$. Consider the following closed subset $Y$ of $X\times \widehat{\mathbb{CP}}^m$, $$Y :=\{(x,[L])\in X\times \widehat{\mathbb{CP}}^m : x\in L\}.$$ By hypothesis, the open complement $U$ of $Y$ in $X\times \widehat{\mathbb{CP}}^m$ is an affine space bundle over $\widehat{\mathbb{CP}}^m$. By the Leray spectral sequence for cohomology applied to the second projection, $$\text{pr}_2:X\times \widehat{\mathbb{CP}}^m \to \widehat{\mathbb{CP}}^m,$$ the cohomology of $U$ equals the cohomology of $\widehat{\mathbb{CP}}^m$. In particular, the cohomological dimension of $U$ equals $2m$.

On the other hand, we also have the first projection, $$\text{pr}_1:X\times \widehat{\mathbb{CP}}^m \to X.$$ The restriction of $\text{pr}_1$ to $U$ is again an affine space bundle, but now of relative dimension $m$. Thus, the cohomology of $U$ also equals the cohomology of $X$. In particular, the cohomological dimension of $U$ equals $2n$.

Since the cohomological dimension of $U$ equals both $2n$ and $2m$, the dimension $n$ of $X$ equals the dimension $m$ of the ambient projective space $\mathbb{P}^m$. Therefore $X$ equals $\mathbb{P}^m$. **QED**

However, this is an interesting question, and variants often arise (with weaker hypotheses, of course). So here are some further observations.
One of the coarsest topological invariants is the Euler characteristic of cohomology with compact support. For a complex algebraic variety $X$ considered as a set of $\mathbb{C}$-rational points with the classical / Euclidean / analytic topology, for a Zariski closed subset $Z\subseteq X$ with its induced topology, and for the open complement $X\setminus Z$ with its induced topology, there is a long exact sequence of compactly supported cohomology, $$\dots \to H^r_c(X\setminus Z;\mathbb{Z}) \to H^r_c(X;\mathbb{Z}) \to H^r_c(Z;\mathbb{Z}) \xrightarrow{\delta} H^{r+1}_c(X\setminus Z;\mathbb{Z})\to \dots $$ This gives rise to an equality of compactly supported Euler characteristics, $$\chi_c(X) = \chi_c(X\setminus Z) + \chi_c(Z).$$

Thus, for a linearly nondegenerate, irreducible, Zariski closed subset $X$ of $\mathbb{P}^n$ that is smooth, if for every hyperplane section $H$ the open complement $X\setminus H$ has equal Betti numbers, then also the Euler characteristic $\chi_c(H)$ is independent of the choice of hyperplane section.

On the other hand, for a field $k$ of **characteristic zero**, such as $k=\mathbb{C}$, for an integral closed subscheme $X$ of $\mathbb{P}^n_k$ that is smooth, a general pencil $(H_t)_{t\in \Pi}$ of hyperplane sections $H_t$ will be a **Lefschetz pencil**. There are many references for this; one reference is Corollary 2.10, p. 46 of the following.

*Voisin, Claire*, Hodge theory and complex algebraic geometry. II. Transl. from the French by Leila Schneps, Cambridge Studies in Advanced Mathematics. 77. ZBL1032.14002.

In positive characteristic, this can fail, although it is often still true. The standard reference is the second volume of SGA 7.

In characteristic $0$, there will be only finitely many elements $t$ of the pencil, say $t\in\{t_1,\dots,t_\delta\}$, such that $H_t$ is singular, and each singular member $H_t$ will have a single ordinary double point. The finite set $\{t_1,\dots,t_\delta\}$ is the **discriminant locus**. For each such $t$, the Betti numbers of $H_t$ and of the nearby fibers $H_s$ will differ in precisely one degree, coming from a vanishing cycle, so that the difference of Betti numbers is $\pm 1$ (depending on the parity of the cohomological degree of the vanishing cycle). Thus, $\chi_c(H_t)-\chi_c(H_s)$ equals $+1$ or $-1$ for every $t$ in the discriminant locus. The precise cardinality of the discriminant locus is computed in my answer to a previous MathOverflow question: Bounding the number of critical points in a Lefschetz pencil

If this cardinality is nonzero, then there are hyperplane sections with varying Euler characteristics, and thus there open complements also have varying Euler characteristic. When the cardinality of the discriminant set equals $0$, then $X$ has **defective dual variety**, sometimes also called "defective discriminant variety", "degenerate dual variety", "degenerate discriminant variety", etc.

Starting with Griffiths-Harris, then Ein, and then many others, varieties with defective dual variety have been classified in low dimensions. One general result proved by Beltrametti-Fania-Sommese is that every such variety admits a Fano fibration (possibly with base equal to a point) whose general fiber is a Fano manifold that also has defective dual variety. However, for a general hyperplane section $H$, since $H$ is irreducible (I am assuming that $\text{dim}(X)\geq 2$ since the result is trivial in dimension one), the exact sequence of Picard groups gives $$\mathbb{Z}\cdot [H] \to \text{Pic}(X) \to \text{Pic}(X\setminus H) \to 0.$$ If $X\setminus H$ is affine space for a general hyperplane section $H$, then $\text{Pic}(X\setminus H)$ is zero. Thus, $\text{Pic}(X)$ equals $\mathbb{Z}\cdot [H]$. If the target of the fibration has positive dimension, then the pullback of an ample divisor class from the target contradicts that $\text{Pic}(X)$ equals $\mathbb{Z}\cdot [H]$. Therefore,
if $X$ is a variety with defective dual variety such that $X\setminus H$ is an affine space for a general hyperplane section $H$, then $X$ is a Fano manifold (hence simply connected) with Picard rank $1$.

By a theorem of Fujita and Libgober-Wood, the only fake projective spaces of dimension $\leq 6$ that are simply connected are honest projective spaces. In conclusion, for a smooth projective variety $X$ of dimension $n\leq 6$, if $X$ has dual defective variety and if $X\setminus H$ is isomorphic to affine space for a general hyperplane section $H$ of $X$, then $X$ is isomorphic to projective space, and $H$ is a general linear hyperplane in that projective space.