The finite-dimensional case is simplest, so let's begin there. If an operator $A$ is self-adjoint, then it can be decomposed as
$$A:= \sum_{\lambda\in \Lambda} \lambda \cdot \Pi_\lambda^A$$
where $\Lambda$ is the set of eigenvalues of $A$ and $\Pi^A_\lambda$ is the orthogonal projection operator onto the eigenspace of $A$ corresponding to the eigenvalue $\lambda$. As a few examples,
$$A = \pmatrix{2 & 0 \\ 0 & 4} = 2 \cdot \pmatrix{1&0\\0&0} + 4\cdot \pmatrix{0&0\\0&1}$$
$$B = \pmatrix{0 & 1 \\ 1 &0} = 1 \cdot \pmatrix{\frac{1}{2} & \frac{1}{2} \\ \frac{1}{2} & \frac{1}{2}} + (-1) \cdot \pmatrix{\frac{1}{2} & -\frac{1}{2}\\-\frac{1}{2} & \frac{1}{2}}$$
For a system in the pure state $\psi$, the probability of measuring the observable (represented by) $A$ to have value $\lambda$ is given by the following:
$$\mathrm{Prob}_\psi(A,\lambda):= \frac{\langle \psi,\Pi_\lambda^A \psi\rangle}{\langle \psi,\psi\rangle}$$
In order to frame this somewhat more cleanly in terms of probability theory, we generalize this as follows. Let $E\subseteq \mathbb R$ be some set of possible measurement results (e.g. "we measured the observable $A$ to lie in the set $E$"). We define a map $\mu_A$ which has the following properties:
- $\mu_A(\mathbb R) = \mathbb I$, the identity map on the Hilbert space
- $\mu_A(\emptyset) = 0$, the zero map on the Hilbert space
- If $E_i$ are a countable collection of disjoint subsets of $\mathbb R$, then
$$\mu_A\left(\bigcup_i E_i\right) = \sum_i \mu_A(E_i)$$
- For each $\lambda \in \Lambda$, $\mu_A(\{\lambda\}) = \Pi^A_\lambda$
A map satisfying properties 1-3 is called a projection-valued measure; property 4 provides the unique PVM associated to the self-adjoint operator $A$. Given the appropriate PVM, we can map a set $E$ - representing a possible outcome of a measurement - to a projection operator $\mu_A(E)$; from there, it is this projection operator to which we assign a probability.
In that sense, the projection operator $\mu_A(E)$ plays the role of an event which may be familiar from probability theory, while the state $\psi$ plays the role of a probability measure
$$\mu_A(E) \mapsto \frac{\langle \psi,\mu_A(E)\psi\rangle}{\langle\psi,\psi\rangle}\in [0,1] \qquad (\star)$$
To recap: given an observable $A$, we can decompose it as a linear combination of projection operators. The projection-valued measure $\mu_A$ associates a measurement outcome $E$ with a projection operator $\mu_A(E)$. Given a state $\psi$, the probability of measuring $A$ to have a value in $E$ is then given by $(\star)$.
The generalization to infinite-dimensional Hilbert spaces is immediate, provided that the spectrum of $A$ is discrete. However, infinite-dimensional Hilbert spaces bring with them the possibility that the spectrum of $A$ is continuous, or possibly a mixture of both discrete and continuous.
The spirit of the above discussion remains precisely the same; the major technical distinction comes in how one defines a PVM for a continuous spectrum. I think the clearest way to do this is by example.
Position Operator
The PVM associated to the position operator (in the position basis) is given by
$$\mu_X(E):= \chi_E \mathbb I \quad \text{ where }\quad \chi_E(x)=\begin{cases} 1 & x\in E \\ 0 & x\notin E\end{cases}$$
is the indicator function on $E$. Given a wavefunction $\psi$ (which I assume to be normalized, purely for convenience), the question "what is the probability of measuring $X$ to lie in $E$?" is answered by
$$\mathbb P_\psi(X,E) :=\langle \psi, \mu_X(E)\psi\rangle = \int_\mathbb R \chi_E(x)\cdot |\psi(x)|^2 \mathrm dx = \int_E |\psi(x)|^2\mathrm dx$$
which is indeed what we learned in our first class in quantum mechanics.
Momentum Operator
The PVM associated to the momentum operator is (unsurprisingly) the indicator function in the momentum basis. In the position basis, one first takes the Fourier transform, then multiplies by the indicator function, then inverse-Fourier transforms back:
$$\mathbb P_\psi(P,E) :=\langle \psi, \mu_P(E)\psi\rangle = \int_\mathbb R \chi_E(p)\cdot |\tilde\psi(p)|^2 \mathrm dp = \int_E |\tilde\psi(p)|^2\mathrm dp$$
where $\tilde \psi(p) = \frac{1}{\sqrt{2\pi\hbar}}\int \psi(x) e^{-ipx/\hbar} \mathrm dx$ is the Fourier transform of $\psi(x)$.
In the preceding examples, we saw that the PVM was either an indicator function or an indicator function conjugated with a unitary operator (in this case, the Fourier transform operator); this is a general feature. That is, for every observable $A$ with continuous spectrum, the projection-valued measure can be expressed as
$$\mu_A(E) = U^\dagger \cdot \chi_E \mathbb I \cdot U$$
for some unitary operator $U$, which in physics parlance transforms us to the (continuous) eigenbasis of $A$. In this light, the standard procedure of solving for the (non-normalizable) eigenfunctions of $A$ can be viewed as a quest to find this $U$.
As a final note, in the above description we defined probability measures (i.e. maps which assign probabilities to projection operators) via elements of the Hilbert space $\psi$ as $\Pi \mapsto \frac{\langle \psi,\Pi\psi\rangle}{\langle\psi,\psi\rangle}$. It turns out that this is not the most general notion of probability measure we could use. Given a density matrix $\rho$, the appropriate probability measure is given by
$$\Pi \mapsto \mathrm{Tr}\big(\Pi \rho)\in [0,1]$$
but other than that, the formalism remains the same.