The usual approach for formally proving that $2+2=4$ is to start from Peano's axioms (which define the set $N$ of natural numbers , $0\in N$ and a successor function on $N$). Using these axioms, along with the rules of logic and set theory, you can formally prove that there exists a unique binary function $+$ such that
$x+0 = x$
$x+(y+1) = (x+y)+1$
where $1$ is the successor of $0$, and $n+1$ is the successor of $n$.
This is a long and tedious process. (Earlier versions of Peano's axioms gave you the above definition to start.)
Then you define 2, 3 and 4 such that
Then you have $2+2=2+(1+1)=(2+1)+1=3+1=4$