That's because they are oppositely charged that they can form a bound state: even classically you can understand that: oppositely charged charges attract each other.
While it is true that a particle and its antiparticle can annihilate each other, they first have to interact.
Positronium is a purely electromagnetic bound state: the positron and the electron will form a bound state by electromagnetic interaction (no strong interaction as they are leptons, and the weak interaction does not play a role to form the bound state).
They have the same mass, but it is not a real problem.
Quantum mechanically this problem is treated exactly the same way as the textbook example of the hydrogen atom. You first separate the centre of mass from the problem, but here as they have the same mass this cannot be neglected in the final result.
Then you calculate the interaction of one particle with the centre of mass (in the case of the H atom, this is unambiguously the interaction of the electron with the proton, but here it is one of the two lepton with the centre of mass which is in the middle).
I should also be noted that even if the bound state is stable from that point of view, the positronium will eventually annihilate because the two wave function will overlap and thus these two anti-particles can interact and annihilate.
Positronium can be formed in a variety of ways, one example, where you can create positronium in your bathroom is to have an element which is $\beta^+$ unstable. After this decay, a positron is emitted. It can then interact with the very large number of electron present in the matter and they can form a bound state: the positronium.