Legal transition refers to the process of changing your name and gender marker on legal documents to more accurately reflect your gender identity. Depending on where you are, this can be a very lengthy and tedious process. Documents include someone's state ID, driver's license, birth certificate, social security number, and immigration documents (such as permanent resident card, or naturalization certificate). Legal transition typically includes being out as trans to health professionals, and with your school or employer.
Depending on the location, it may not be possible to have your gender marker or legal name changed on documents due to local laws. Some places require that transgender people undergo certain surgeries, hormonal treatments, and/or forced sterilization prior to having their legal name and/or gender changed. Some places require a fee and/or for your legal transition to be documented in a local newspaper. Sometimes it is required to appear in front of a judge to confirm that you are changing your name for the purposes of gender transition, and not to avoid debts or commit fraud.
Most transgender people have a desire to change their legal name and gender to reflect their proper identity. In some cases, this can be a matter of safety. Having the incorrect name and/or gender marker on legal paperwork (particularly an often-used ID card or driver's licence) can put someone at risk of transphobia (such as discrimination and violence).
Some nonbinary and intersex people have the option of selecting X on their legal identification instead of M (male) and F (female). The ability to do this will vary based on location.
I am not a lawyer and cannot tell you exactly how to change your legal identification. I can tell you that as of me writing this, in the state of New York in The United States, that all that is required to change your gender on your state identification card is to circle the letter which corresponds to your gender identity (M, F, X) while renewing your ID card. I can also direct you to the links below for potentially more useful information than what I've written here myself.