The short answer is that it happens more often than it should, and the mechanics are not complicated when someone is willing to deceive people who trust them.
From inside a facility, an inmate can correspond with multiple people simultaneously. Letters, phone calls, and visits are not cross-referenced against each other. The person calling on Monday does not know who called on Tuesday. The woman sending money does not know about the woman sending letters. The facility has no interest in managing the romantic lives of the people in its custody, and there is no system that flags conflicting relationship statuses.
Getting engaged while married is not a legal act on its own. An engagement is a personal promise, not a legal contract. Someone can tell a pen pal or a new connection that they are engaged without any paperwork changing hands. Whether that promise is made in good faith is a different question entirely.
What is not legal is getting married again while already legally married. Bigamy is a crime in every state. If your person married someone while a prior legal marriage was still in effect, that second marriage is void and the person could face criminal charges depending on the jurisdiction and whether anyone chooses to pursue it.
If you are the wife in this situation and you have discovered this while he is still incarcerated, that window of time while he is inside and unable to manage the fallout is actually your best opportunity to get clarity, consult an attorney, and make decisions about your next steps without pressure.
A divorce lawyer is the right first call. Protect yourself legally before anything else.