If we consider that a context is an unital abelian sub-$C^*$-algebra of some unital $C^*$-algebra $\mathscr{A}$, that agree on the unit, then if we define:
Definition: Let $A$ be a unital $∗$-algebra, and $\{A_n\}_{n∈I}$ a collection of self-adjoint commuting elements, then there is at least one context containing $\{A_n\}_{n∈I}$, namely the space of all polynomials of $\{A_n\}_{n∈I}$, then we can consider the smallest of all such contexts $\,\bigcap \{C ⊆ \mathscr{A} \,\, | \,\, C \text{ is a context containing } \{A_n\}_{n\in I}\}$,$\,$ and this context is said to be the context generated by $\{A_n\}_{n∈I}$, denoted by $\mathcal{C}(\{A_n\}_{n∈I})$.
How could I prove then that for a self-adjoint $A$: $$\mathcal{C}(\{A\})= \{ f(A) \,\,|\,\, f:\sigma(A) \rightarrow \mathbb{R}\,\, \text{ is a Borel measurable function}\}$$
For the special case of matrices I have read a proof using the spectral decomposition of such matrices, realizing that these decompositions are finite and that for $A= \sum\limits_{i=1}^n\lambda_iP_i$ each of the $P_i$ must be in the context $\mathcal{C}(\{A\})$, since a context is a unital $*$-sub-algebra, hence: $$\mathcal{C}(\{A\}) \ni A-\lambda_2 = \sum\limits_{i=1}^n\lambda_iP_i-\lambda_2\sum\limits_{i=1}^n P_i =\sum\limits_{i=1}^n (\lambda_i-\lambda_2)P_i \in \mathcal{C}(\{A\})$$ $$\mathcal{C}(\{A\}) \ni \sum\limits_{i=1}^n (\lambda_i-\lambda_2)P_i-\lambda_3 = \sum\limits_{i=1}^n (\lambda_i-\lambda_2-\lambda_3)P_i \in \mathcal{C}(\{A\})$$ $$\vdots$$ $$\lambda_1P_1 \in \mathcal{C}(\{A\})$$
Where we can get to each projector $P_i$ because the sum is finite, hence $\{P_i\}_{i=1}^n \subset \mathcal{C}(\{A\})$. Since $f(A) = \sum\limits_{i=1}^n f(\lambda_i)P_i$ by the spectral theorem for matrices, then $\{ f(A) \,\,|\,\, f:\sigma(A) \rightarrow \mathbb{R}\,\, \text{ is a Borel measurable function}\} \subseteq \mathcal{C}(\{A\})$, also because of the spectral decomposition theorem for matrices, the elements of $\{ f(A) \,\,|\,\, f:\sigma(A) \rightarrow \mathbb{R}\,\, \text{ is a Borel measurable function}\}$ commute two by two, and that set is trivially a unital $*$-sub-algebra, hence a context that contains $A$, hence $\mathcal{C}(\{A\}) \subseteq \{ f(A) \,\,|\,\, f:\sigma(A) \rightarrow \mathbb{R}\,\, \text{ is a Borel measurable function}\}$ that then makes $\mathcal{C}(\{A\}) = \{ f(A) \,\,|\,\, f:\sigma(A) \rightarrow \mathbb{R}\,\, \text{ is a Borel measurable function}\}$.
But in this proof the fact that the spectral decomposition is finite is fundamental for this proof to work, for a general unital $*$-algebra $\mathscr{A}$ this is not true, since the spectral decomposition would be given by $A= \int_{\sigma(A)} \lambda dP^{(A)}(\lambda)$ for a continuous projective valued measure $dP^{(A)}$. Is there a way to prove this whithout using this finite requirement? This theorem is necessary for I to be able to generalise another such theorem that was also proved for matrices in the reference, but that is said to be "easly generalized" for a more general unital $*$-algebra $\mathscr{A}$, this lemma being the only difficulty in my trial to do so.
To my opinion, the definition you quote is badly written.
Let $\mathscr{A}$ be a $*$-algebra. For $S \subset \mathscr{A}$ consisting only of self-adjoint elements that commute one with another, consider the algebra of formal polynomials with one indeterminate $X_s$ for each element $s$ of $S$. Let us denote it by $\mathbb{C}[S]$. Then (exercise) there is a unique $*$-algebra morphism
$eval : \mathbb{C}[S] \rightarrow \mathscr{A}$ sending each $X_s$ to $s$. The image of this map is called the set of polynomials in $S$ and (exercise) it is the smallest sub-$*$-algebra of $\mathscr{A}$ containing $S$.
Now, turning to your question.
Consider the simple case of $S = \{A\}$, and assume that there exists a finite set $\mathcal{P}$ of mutually commuting self-adjoint idempotents that sum to the identity and a family $(\lambda_P)_{P \in \mathcal{P}}$ such that $A = \sum_{P \in \mathcal{P}} \lambda_P P$. Then, for all $f : \mathbb{R} \rightarrow \mathbb{R}$, we define $f(A) := \sum_{P \in \mathcal{P}} f\left(\lambda_P\right) P$. Note that for $f$ a polynomial function, the two definitions of $f(A)$ coincide. The the map $eval : \mathbb{R}^\mathbb{R} \rightarrow \mathscr{A}$ is also a a $*$-algebra morphism, therefore the image of this map contains the context generated by $A$. However, it turns out to be exactly the context generated by $A$: indeed, let $f$ be an arbitrary function $\mathbb{R} \rightarrow \mathbb{R}$. Then by Lagrange's interpolation theorem, there exists a polynomial $Q$ such that for all $P$, $f\left(\lambda_P\right) = Q\left(\lambda_P\right)$. Therefore, $f(A) = Q(A)$, so $f(A)$ is a polynomial in $A$.
Now, let us consider some self-adjoint element $A$ that cannot be written as before. Then, we cannot, in general, define $f(A)$! To do this, we generally need to consider some topology on $\mathscr{A}$, write $f$ as a limit (in some sense) of polynomials, and we try to transfer the convergence of functions to the convergence of elements. For example, if $\mathscr{A}$ is endowed with a $C^*$-norm and complete, we can reach all continuous $f$'s; if $\mathscr{A}$ is a closed subset of the set of bounded operators on a Hilbert space, endowed with the weak operator topology, we can reach all Borel function $f$'s. In this cases, if you require that a context must be the smallest closed thing, you get more than polynomials of $A$ in the context generated by $A$.
Now, an example. Consider a separable Hilbert space, an orthonormal basis $(\xi_n)_n$ and the bounded operator $A$ defined by, for all $n$, $A\xi_n = \frac{1}{n} \xi_n$ if $n$ is nonzero, and $0$ if $n$ is zero. Then the operator $B$ defined by, for all $n$, by $B\xi_n=0$ if $n$ is nonzero, and $B\xi_0=\xi_0$. Then $B$ is the image of $A$ by a Borel function, but it isn’t a polynomial in $A$. Therefore, your claim is wrong.