Let $\mu, \nu$ be two probability measures that agree on $\mathcal P.$ Without loss of generality, assume $\varnothing, \Omega \in \mathcal P.$ Let $\mathcal B$ be the set of all finite unions $A_1 \cup \cdots \cup A_n$ for $A_1,\dots, A_n \in \mathcal P,\ n \ge 1.$ Let's show that both measures agree on $\mathcal B.$
$$\mu(A_1 \cup \cdots \cup A_n) = \sum_{1 \le i_1 < \cdots < i_k \le n \\ k = 1,\dots,n} (-1)^{k-1} \mu(A_{i_1} \cap \cdots \cap A_{i_k}) = \sum_{1 \le i_1 < \cdots < i_k \le n \\ k = 1,\dots,n} (-1)^{k-1} \nu(A_{i_1} \cap \cdots \cap A_{i_k})= \nu(A_1 \cup \cdots \cup A_n). $$
An overcomplicated formula for a simple fact: because $\mathcal P$ is a $\pi$-system, the two measures coincide on the finite intersections $A_{i_1} \cap \cdots \cap A_{i_k},$ and the measure of the union $A_1 \cup \cdots \cup A_n$ is determined by those (by the principle of inclusion-exclusion). Hence the measures agree on $\mathcal B.$
Note that $\mathcal B$ is a lattice. That is, the union of two sets in $\mathcal B$ is in $\mathcal B$ (which is obvious from the definition) and the intersection of two elements in $\mathcal B$ is in $\mathcal B$ (because intersection distributes over union and $\mathcal P$ is a $\pi$-system).
Now, I am going to proceed using induction, because sets in $\mathcal A$ can be written by applying finitely many set operations to the sets in $\mathcal P.$ However, if possible I recommend a more structured approach, where we directly specify what the sets in $\mathcal A$ look like (I haven't found a simple expression).
Let $\mathcal P'$ consist of all the differences $A \setminus B$ for $A, B \in \mathcal B.$ Then $\mathcal P'$ is a $\pi$-system. For, whenever we are given two of its elements as $A \setminus B,\ C \setminus D,$ where $A,B,C,D \in \mathcal B,$ then
$$(A \setminus B) \cap (C \setminus D) = (A \cap C) \setminus (B \cup D)$$
is in $\mathcal P'$ (because $\mathcal B$ is a lattice). Furthermore,
$$ \mu(A\setminus B) = \mu(A) - \mu(B \cap A) = \nu(A) - \nu(B \cap A) = \nu(A \setminus B).$$
That is, both measures agree on $\mathcal P'.$ It is also clear by construction that
$$\mathcal P \subseteq \mathcal B \subseteq \mathcal P' \subseteq \mathcal A.$$
So we can apply the exact same process to $\mathcal P',$ obtaining a lattice and a larger $\pi$-system on which the measures agree. Going on like this, we obtain a sequence
$$\mathcal P = \mathcal P_0 \subseteq \mathcal B_0 \subseteq \mathcal P_1 \subseteq \mathcal B_1 \subseteq \cdots \subseteq \mathcal A.$$
The measures agree on each $\mathcal P_n$ and on every $\mathcal B_n.$ It suffices to show that the limit
$$\bigcup_{n \in \mathbb N} \mathcal P_n = \bigcup_{n \in \mathbb N}\mathcal B_n,$$
in which the measures clearly agree,
is an algebra (and because it is contained in $\mathcal A,$ which is the smallest algebra containing $\mathcal P,$ necessarily it is equal to $\mathcal A$). It's good to prove this statement if one does not find it obvious.
(This is the main idea of my attempt to prove the full Dynkin's theorem.)